1
經過很多努力,我完全無法讓addMethod正常工作。jquery驗證器addMethod不起作用
代碼我有如下:
$("#submitform").validate(
{
rules: {
org_name: "required",
email_address: "required",
phone: "required",
abn: "required",
description: "required",
geocomplete: "required"
},
messages: {
org_name: "Required",
email_address: "Required",
phone: "Required",
abn: "Required",
description: "Required",
geocomplete: "Required"
},
submitHandler: function(event, validator) {
// submitForm();
},
invalidHandler: function(event, validator) {
//code..
}
});
的addMethod
$.validator.addMethod("org_name", function(value) {
// return this.optional(element) || value == params[0] + params[1];
console.log("hi" + value);alert('hi');
return false;
}, "Invalid");
和目標元素
<input id="org_name" name="org_name" type="text" class="input-xlarge ">
的addMethod功能不會被調用時,不存在錯誤和我在這一個損失? 另一方面,「必需」驗證在預期的窗體上工作正常,這是我第一次進入這個插件。
請參閱本http://jqueryvalidation.org/jQuery.validator.addMethod/ – krutssss