字段集之间的验证

问题描述:

我正在使用带有bassistance验证的formtowizard jquery插件。我重视我的下一个按钮,但是这验证我的形式我只希望它来验证当前字段集而不是整个形式的click事件...字段集之间的验证

我的形式设置这样

<form id="SignupForm" method="POST" action=".................."> 

    <fieldset> 
    <legend>Application</legend> 
     <div> 

     </div> 
    </fieldset> 

    <fieldset> 
    <legend>Step Two</legend> 
     <div> 

     </div> 
    </fieldset> 

这就是我用的那一刻

$("a.next").click(function() { 
    $("#SignupForm").validate(); 
    }); 

这是我的按钮被称为

function createNextButton(i) { 
      var stepName = "step" + i; 
      $("#" + stepName + "commands").append("<a href='#' id='" + stepName + "Next' class='next'>Next</a>"); 

      $("#" + stepName + "Next").bind("click", function(e) { 
       /* VALIDATION */ 
       if (options.validationEnabled) { 
        var stepIsValid = true; 
        $("#"+stepName+" :input").each(function(index) { 
         checkMe = element.validate().element($(this)); 
         //stepIsValid = !element.validate().element($(this)) && stepIsValid; 
         stepIsValid = checkMe && stepIsValid; 
        }); 
        //alert("stepIsValid === "+stepIsValid); 
        if (!stepIsValid) { 
         return false; 
        }; 
       }; 

       $("#" + stepName).hide(); 
       $("#step" + (i + 1)).show(); 
       if (i + 2 == count) 
        $(submmitButtonName).show(); 
       selectStep(i + 1,'next'); 
      }); 
     } 

任何想法的人?

+0

任何想法吗? – 2010-12-09 13:22:33

好,我已经成功地解决我的问题,如果其他人想知道......

function createNextButton(i) { 
    var stepName = "step" + i; 
    $("#" + stepName + "commands").append("<a href='#' id='" + stepName + "Next' class='next'>Next</a>"); 

    $("#" + stepName + "Next").bind("click", function(e) { 

     if (options.validationEnabled) { 
      var stepIsValid = true; 
      $("#"+stepName+" :input").each(function(index) { 
       checkMe = element.validate().element($(this)); 
       //stepIsValid = !element.validate().element($(this)) && stepIsValid; 
       stepIsValid = checkMe && stepIsValid; 
      }); 
      alert("stepIsValid === "+stepIsValid); 
      if (!stepIsValid) { 
       return false; 
      }; 
     }; 

     $("#" + stepName).hide(); 
     $("#step" + (i + 1)).show(); 
     if (i + 2 == count) 
      $(submmitButtonName).show(); 
     selectStep(i + 1,'next'); 
    }); 
}