我正在使用 jQuery Validation 插件来验证我的表单,但即使在成功验证后表单也不会提交。这是重现该问题的代码:
<?php
if(isset($_REQUEST['submit'])){
echo "form submitted"; //have to insert into database here
}
?>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>
<script type="text/javascript">
jQuery.validator.setDefaults({
debug: true,
success: "valid"
});;
</script>
<script>
$(document).ready(function(){
$("#myform").validate({
rules: {
field1: {
required: true,
number: true
},
field2: {
required: true,
number: true,
minlength: 3
},
field3: {
required: true,
email: true
}
}
});
});
</script>
<form id="myform" method="post" action="">
<div>
<label for="field">Required, decimal number: </label>
<input class="left" id="field1" name="field1" type="text" />
</div>
<br>
<div>
<label for="field">Required, Minimum length 3: </label>
<input class="left" id="field2" name="field2" type="text" />
</div>
<br>
<div>
<label for="field">Required, email: </label>
<input class="left" id="field3" name="field3" type="text" />
</div>
<br/>
<input type="submit" name="submit" value="Validate!" />
</form>
请注意,无论表单标签中是否存在有效操作,都会发生这种情况。
这可能是什么原因造成的?