[英]Jquery Validation Rule Depends Generates Uncaught TypeError
当我尝试使用jQuery验证规则时,取决于以下内容:
<script>
$('#sign-up-form form').validate({
rules: {
state: "required",
school: {
depends: function(element) {
return $("#id_school_id").val().length;
}
}
}
});
</script>
每次规则的依赖部分运行时,我都会得到Uncaught TypeError: Cannot read property 'call' of undefined
我要检查的ID在那儿(#id_school_id)。 我正在使用jquery.validation.js v 1.11.1
我误会了,要说是规则方法。 您需要将其值应用于规则方法。 因此,例如
$('#sign-up-form form').validate({
rules: {
state: "required",
school: {
required: {
depends: function(element) {
return $("#id_school_id").val().length;
}
}
}
},
messages: {
school: "Please choose a valid school name from the choices presented"
}
});
</script>
是否需要字段“学校”取决于字段“ school_id”的长度。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.