在单个字段上覆盖 2 条消息
Override 2 messages on single field
我有以下 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.
你能建议如何覆盖这两条消息吗?
P.S.
当我编写以下配置时:
messages: {
email: "invalid email",
password: "too simple password",
confirm_password: "too simple password",
equalTo: "wrong password confirmation"
}
即使我的密码长度等于 10 但不同,我也会看到消息 too simple password
试试这个:
messages: {
password: {
minlength: 'Your password must be at least 3 characters long',
maxlength: 'Your password cannot exceed 15 characters',
equalTo: "wrong password confirmation"
}
}
我有以下 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.
你能建议如何覆盖这两条消息吗?
P.S.
当我编写以下配置时:
messages: {
email: "invalid email",
password: "too simple password",
confirm_password: "too simple password",
equalTo: "wrong password confirmation"
}
即使我的密码长度等于 10 但不同,我也会看到消息 too simple password
试试这个:
messages: {
password: {
minlength: 'Your password must be at least 3 characters long',
maxlength: 'Your password cannot exceed 15 characters',
equalTo: "wrong password confirmation"
}
}