我正在使用javascript-coder.com的gen_validatorv4.js来验证表单。我喜欢它,因为设置正常使用非常简单。但是现在我遇到了一个无法修复的设置。
这就是我想要做的。我有一个表单来编辑用户的名称,用户名和密码等字段。问题是我希望脚本只有在它不为空时验证密码字段。
我试过这种方式,但它不起作用:
function DoCustomValidation() {
var frm = document.forms["edit_validate"];
if(frm.uPass.value != '') {
frmvalidator.addValidation("uPass","minlen=8","Minimum 8 characters")
frmvalidator.addValidation("uPass2","req","Passwords missing");
frmvalidator.addValidation("uPass2","eqelmnt=uPass","Password fields doesn't match");
frmvalidator.addValidation("uPass","neelmnt=uName","User name and password can't be the same");
return true;
} else {
return false;
}
}
frmvalidator.setAddnlValidationFunction(DoCustomValidation);
任何想法?
每个
答案 0 :(得分:1)
刚刚在ehow上发现了这个!
frmvalidator.addValidation("PASSWORD2","eqelmnt=PASSWORD",
"The confirmed password is not same as password");