Submit Handler not working

末鹿安然 提交于 2019-12-12 03:48:48

问题


The code I am using below is validating correctly but not submitting when fields are valid:

<script>
  $(document).ready(function(){
    $("#verifyformDesktop").validate({
   errorContainer: "#messageBox1, #messageBox2",
   errorLabelContainer: "#messageBox1 ul",
   wrapper: "li", debug:true,
   submitHandler: function(form) {
     form.submit();
   }
 })
});
</script>

<form name="verifyformDesktop" id="verifyformDesktop" action="php/verify.php" method="post">
...
<input type="submit" name="submit" id="submit" value="ENTER">

Maybe the submitHandler?


回答1:


Remove debug: true, from your .validate() options.

It's only used for testing and blocks the submit.

debug: Enables debug mode. If true, the form is not submitted...

http://docs.jquery.com/Plugins/Validation/validate#toptions

Working Demo:

http://jsfiddle.net/FHAV2/

You also do not need to declare a submitHandler: function...

submitHandler: function(form) {
    form.submit();
}

... because that's simply the default plugin behavior when you leave it out.

However, if you need to do other things, then it is correct...

submitHandler: function(form) {
    // do some other stuff before submit
    form.submit();
}


来源:https://stackoverflow.com/questions/14366899/submit-handler-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!