我有以下jquery验证配置:
$('form[name=register_form]').validate({
rules: {
email: {
required: true,
email: true
},
password: {
minlength: 3,
maxlength: 15
},
confirm_password: {
minlength: 3,
maxlength: 15,
equalTo:"#password"
}
},
messages: {
email: "You should input real email adress!"
}
}
正如您所见,字段password
和confirm_password
有2个限制。
1. length 3 -15
2. Its should be equal.
您能否建议如何覆盖这两条消息?
当我写下面的配置时:
messages: {
email: "invalid email",
password: "too simple password",
confirm_password: "too simple password",
equalTo: "wrong password confirmation"
}
即使我的密码长度等于10但不同,我也会看到消息too simple password
答案 0 :(得分:2)
试试这个:
messages: {
password: {
minlength: 'Your password must be at least 3 characters long',
maxlength: 'Your password cannot exceed 15 characters',
equalTo: "wrong password confirmation"
}
}