我尝试使用Jquery,我需要使用提交处理程序在提交时传递表单的值,这不起作用。我是Jquery的新手,不知道出了什么问题。以下是我的Javascript代码
$('document').ready(function() {
jQuery.validator.addMethod('minStrict', function(value, el, param) {
if (value == '') {
return true;
}
return value >= param;
});
$.validator.addMethod('reqStrict', function(value, el, param) {
alert(value);
alert(el.id);
alert(value == '');
return value.length >= param;
});
$('#form1').validate({
rules: {
keyword1: {
reqStrict: 1
},
MinPrice: {
minStrict: 0,
number: true
},
MaxPrice: {
minStrict: function(element) {
return $("#MinPrice").val() > 0 ? $("#MinPrice").val() : 0;
},
number: true
},
MaxHandlingTime: {
minStrict: 1,
digit: true,
}
},
messages: {
keyword1: "Please enter a keyword",
MinPrice: {
minStrict: "Minimum price cannot be below 0",
number: "Price should be a valid number "
},
MaxPrice: {
minStrict: "Maximum price cannot be less than minimum price or below 0",
number: "Price should be a valid number "
},
MaxHandlingTime: {
digit: "Max Handling time should be a valid digit",
minStrict: "Max Handling time should be greater than or equal to 1"
}
},
highlight: function(element) {
$(element).closest('.form-group').addClass('has-error');
},
unhighlight: function(element) {
$(element).closest('.form-group').removeClass('has-error');
},
errorElement: 'span',
errorClass: 'help-block',
errorPlacement: function(error, element) {
if (element.parent('.input-group').length) {
error.insertAfter(element.parent());
} else {
error.insertAfter(element);
}
},
submitHandler: function() {
alert("Hey babe");
}
});
});
请你告诉我我哪里出错了。