开发者

Calling validate function on button and getting the result (true/false)

I am tr开发者_开发百科ying to do following task:

$("#btn1").click(function(){

     var success =  $("#myFrm").validate();

      if (success == true)      {
            // post form through ajax
      }
      else{
            // set focus on first field
      }

});


I think you're looking for the valid() method:

$("#btn1").click(function(){

     var success =  $("#myFrm").valid();

      if (success == true)      {
            // post form through ajax
      }
      else{
            // set focus on first field
      }

});

This assumes, of course, that you've configured jQuery validate on the form in question (using $("#myFrm").validate()).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜