当我使用以下代码时,我收到“Uncaught TypeError: Cannot call method 'call' of undefined jquery.validate.min.js:29”,相同的代码在“jquery-1.8.2.js”中工作,但它在“jquery-190.js”中不起作用,如果我从验证中删除“require_from_group:[1,”.customer-identifier”],它的工作。
$(document).on( 'pageinit', '#contact-us-page', function(event){
var $currentPage = $(event.target);
var $form = $currentPage.find("form#customer-identifier");
var validator_contactuspage = $form.validate({
rules: {
account_number: {require_from_group: [1,".customer-identifier"], digits: true, maxlength: 10, minlength: 10},
phone_number: {require_from_group: [1,".customer-identifier"], phoneUS: true}
},
messages: {
account_number: {
maxlength: "Please enter exactly 10 digits.",
minlength: "Please enter exactly 10 digits."
}
},
highlight: function(element, errorClass) {
$(element).removeClass("valid");
$(element).addClass("error");
},
success: function(element, validClass) {
$(element).removeClass("error");
$(element).addClass("valid");
},
submitHandler: function(form){
getAddress();
return false;
}
});
$form.find("input[name=account_number]").bind("keyup change blur", function(event){
if(checkNull($(this).val()).length > 0){
$form.find("input[name=phone_number]").attr("disabled", "disabled");
}
else{
$form.find("input[name=phone_number]").removeAttr("disabled");
}
});
$form.find("input[name=phone_number]").bind("keyup change blur", function(event){
if(checkNull(stripAlpha($(this).val())).length > 0){
$form.find("input[name=account_number]").attr("disabled", "disabled");
}
else{
$form.find("input[name=account_number]").removeAttr("disabled");
}
});
});
编辑:我在 JSFiddle 上添加了我的代码,如果有人想试一试的话。 http://jsfiddle.net/D65WY/36/
有什么想法吗?