jQuery验证插件-自定义消息 [英] jQuery Validation plugin - Custom message
本文介绍了jQuery验证插件-自定义消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是JQuery的新手,正在使用 JQuery验证插件.
I am new to JQuery and am using the JQuery validation plugin.
我想问一下,如何覆盖默认消息以在与表单元素关联的标签中同时显示文本.
I would like to ask, how to override the default messages to display also text in label associated with form element.
我会收到类似这样的消息:
I would get message something like this:
必填字段密码.,而不是默认的必填字段.
字段邮政编码必须至少包含3个字符.,而不是默认的请输入至少3个字符.
我需要重写此插件的默认行为,因为我不想为每种验证类型的每一项指定自定义消息.
I need to override the default behaviour of this plugin, because I do not want to specify custom message for each item for every type of validation.
有可能吗?
推荐答案
$("#signupform")
.validate({
rules: {
password: "required",
postcode: {
required: true,
minlength: 3
}
},
messages: {
password: "Field Password is required",
postcode: {
required: "Field PostCode is required",
minlength: "Field PostCode must contain at least 3 characters"
}
});
这篇关于jQuery验证插件-自定义消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文