2012-10-31 17 views
0

我將如何設置驗證插件的工作不同(添加選項忽略),其上有一類validate-hiddenJQuery驗證插件添加自定義選項,如果窗體有

var theForms = $("form[method=post]:not(.noValidate)"); 
if (theForms.length){ 
    theForms.each(function(){ 
     var $dis = $(this); 
     validater = $dis.validate();   
     if($dis.hasClass("validate-hidden")){ 
      $dis.validate({ ignore: '' }); 
     } 
    }); 
} 

形式I類已經厭倦了這一點,但它沒有忽略選項。

回答

0

我能夠解決這個問題,但使用setDefaults方法和順序。

var theForms = $("form[method=post]:not(.noValidate)"); 
if (theForms.length){ 
    theForms.each(function(){ 
     var $dis = $(this); 
     if($dis.hasClass("validate-hidden")){ 
      jQuery.validator.setDefaults({ 
      ignore: '' 
      }); 
     } 
     validater = $dis.validate();   
    }); 
} 
相關問題