[英]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.