how to check if a form is valid programmatically using jQuery Validation Plugin

前端 未结 7 1856
余生分开走
余生分开走 2020-11-29 19:11

I have a form with a couple of buttons and I\'m using jQuery Validation Plugin from http://jquery.bassistance.de/validate/. I just want to know if there is any way I can che

7条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-29 20:02

    iContribute: It's never too late for a right answer.

    var form = $("form#myForm");
    if($('form#myForm > :input[required]:visible').val() != ""){
      form.submit();
    }else{
      console.log("Required field missing.");
    }
    

    This way the basic HTML5 validation for 'required' fields takes place without interfering with the standard submit using the form's 'name' values.

提交回复
热议问题