custom validation does not seem to get registered.
        Posted  
        
            by viet pham
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by viet pham
        
        
        
        Published on 2010-03-08T00:25:39Z
        Indexed on 
            2010/03/08
            0:30 UTC
        
        
        Read the original article
        Hit count: 351
        
custom
|validation
Hi,
Inside a tab, I have a form that is dynamically loaded via ajax. Since the name of the field is dynamic too (e.g. ), I write a custom validation method inside the "on complete" like this. However, the custom code does not get executed (bolded alert never pops up) no matter what i try.
$.ajax
                    (
                        {
                            url: 'index.php?func=trainingmgr&aAction=displayAddForm', 
                            type: 'GET',
                            dataType: 'html',
                            complete: function(req, err) 
                                {
                                    //Append response to the tab's body 
                                    $(href, '#trainingTabs').append(req.responseText);
                                $.validator.addMethod
                                (   
                                    'tRequired', 
                                    function(value, element) 
                                    {   
                                        if(value == '')
                                           { **alert('I am empty');** return true; }
                                        else return false;
                                    },  
                                    '<br>Required field'
                                );  
                                $('#upload' + index).click
                                (   
                                    function() 
                                    { $('#addForm' + index).validate().numberOfInvalids(); }
                                );  
                            }   
                    }   
                );  
© Stack Overflow or respective owner