我有一个简单的表单,我使用jQuery Validation 插件和jQuery Form 插件来处理表单。
验证没有问题,但表单插件没有提交。
它没有显示控制台的问题,甚至没有显示从脚本发送的任何 ajax 调用。
$("#creatUser").validate({
rules: {
firstname: {
required: true
},
lastname: {
required: true
},
email: {
required: true,
email: true
},
username: {
required: true
},
password: {
required: true,
minlength: 5
},
cpassword: {
required: true,
minlength: 5,
equalTo: '#password'
}
},
invalidHandler: function(form, validator) {
var errors = validator.numberOfInvalids();
if (errors) {
var message = errors == 1
? 'You missed 1 field. It has been highlighted'
: 'You missed ' + errors + ' fields. They have been highlighted';
$("#da-ex-val1-error").html(message).show();
} else {
$("#da-ex-val1-error").hide();
}
},
submitHandler: function(form) {
var options = {
target: '#da-ex-val1-error',
success: function() {
alert('Thanks for your comment!');
},
url: 'php.php',
type: 'POST'
};
// bind form using 'ajaxForm'
$('#creatUser').ajaxForm(options);
}
});