jQuery Validation plugin: how to check if an element is valid?

后端 未结 4 2052
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-15 06:15

A little bit of context:

I\'m using the jQuery Validation plugin to validate a sign-up form. I now want to implement an ajax call to check whether t

4条回答
  •  孤城傲影
    2020-12-15 06:35

    Hello i find exclusive solution, i have the same problem as 47k others & i discover the solution without other jquery plugins or libraries: -first of all we need to register our input in a variable, -then on change checkValidity() if true:mean if valid we assign the registered var to our input to rest it for next change.

            ivar=$('input[name="y-i-name"]')[0];
            $('input[name="y-i-name"]').on('change',function(){
                 if($('input[name="y-i-name"]')[0].checkValidity()){
    
    
                         // your custom code here!
    
    
    
                         $('input[name="y-i-name"]')[0]=ivar; // & now we rest the input for next change validation
                 }
            });
    

提交回复
热议问题