我有规则:
cmp_email: {
minlength: 5,
required: true,
email: true,
remote: {
url: "\/client\/check-email",
type: "post"
}
},
对于remote
规则,我想发出错误消息:"此电子邮件已存在"在alert-error
课内。这是可以使用jQuery验证插件吗?
答案 0 :(得分:1)
有可能,使用messages选项进行jQuery验证。
$('form').validate({
rules: {
cmp_email: {
minlength: 5,
required: true,
email: true,
remote: {
url: "\/client\/check-email",
type: "post"
}
},
},
messages: {
cmp_email: {
remote: "This email already exists"
}
}
});
答案 1 :(得分:0)
是的,这是可能的。为此,您需要以类似的方式为验证插件设置选项。
rules: {
cmp_email: {
minlength: 5,
required: true,
email: true,
remote: {
url: "\/client\/check-email",
type: "post"
}
},
},
messages: {
cmp_email: {
remote: "This email already exist"
}
}
errorClass:"alert-error"