问题
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