[英]jQuery-Validation-Engine - Custom funcCall validation causes error when value is empty
我有一個自定義驗證功能,可以使用jQuery-Validation-Engine驗證兩個密碼字段是否匹配:
<input type="password" class="validate[required,funcCall[checkPassordMatch],maxSize[25]]"...
但是,如果未填充該字段,並且提交了表單,則會收到以下異常:
Uncaught TypeError: Cannot read property 'checkPassordMatch' of undefined
有什么方法只能在輸入被填充或“必需”首先通過的情況下才能運行此驗證?
供參考,我的功能如下:
// Validate the passwords match
function checkPassordMatch(field, rules, i, options){
console.log(field + ' : ' + rules + ' : ' + i + ' : ' + options )
if (field.val() != jQuery("#inputPassword").val()) {
return options.allrules.passwordMatch.alertText;
}
}
贊賞任何想法。
不需要此自定義功能。 我可以用:
validate[required,equals[password]]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.