JQuery Validate验证显示错误提示位置
验证多个Name值相同的元素:
$(".send").click(function () {
var a = 0;
var b = 0;
var c = 0;
var d = 0;
//重置name值
$("input[name^='ContactName']").each(
function () {
$(this).attr('name', 'ContactName[' + a + ']');
a++;
})
$("input[name^='ContactTel']").each(
function () {
$(this).attr('name', 'ContactTel[' + b + ']');
b++;
})
$("input[name^='Position']").each(
function () {
$(this).attr('name', 'Position[' + c + ']');
c++;
})
$("input[name^='Email']").each(
function () {
$(this).attr('name', 'Email[' + d + ']');
d++;
})
$("input[name^='ContactName']").each(
function () {
$(this).rules("add", { required: true, messages: { required: "请填写联系人" },});
$(this).rules("add", { maxlength: 50, messages: { maxlength: "联系人最大长度不能大于50" }, });
})
$("input[name^='ContactTel']").each(
function () {
$(this).rules("add", { required: true, messages: { required: "请填写联系方式" }, });
$(this).rules("add", { maxlength: 50, messages: { maxlength: "联系人最大长度不能大于50" } });
$(this).rules("add", { PhoneCheck: true, messages: { PhoneCheck: "请正确填写您的联系方式" } });
})
$("input[name^='Position']").each(
function () {
$(this).rules("add", { required: true, messages: { required: "请填写职务" }, });
})
$("input[name^='Email']").each(
function () {
$(this).rules("add", { MailCheck: true, messages: { MailCheck: "请填写正确的邮件格式" }, });
//$(this).rules("add", { required: true, messages: { required: "请填写联系邮箱" }, });
})
$("#mainform").submit();
$(this).attr('disabled', true);
if (!$("#mainform").valid()) {
$(this).attr('disabled', false);
}
})
})

显示元素位置:
1 $("#mainform").validate({
errorPlacement: function (error, element) {
if (element.parent().hasClass("input-group")) {
element.parent().after(error);
}
else
element.after(error)
},
errorPlacement: function (error, element) {
error.appendTo(element.parent()); //直接把错误信息加在验证元素后··
},
rules: {
CustomerName: {
required: true,
maxlength: 50,
remote: {
url: '/crm/Customer/CheckCustomName',
type: 'Post',
data: {
CustomerName: function () { return $("#CustomerName").val() },
id: function ()
{
if ($("#Id").val() == undefined) {
return 0;
} else {
return $("#Id").val();
}
}
}
}
},
OwnerId: {
required:true
},
CustomerType:{
required:true
},
Address:{
required: true,
maxlength: 100
},
IndustryId: {
required: true
},
Capital: {
number: true,
min: 0.001,
maxlength: 8
}
},
messages: {
CustomerName: {
required: '请输入客户名称',
maxlength: '客户名称最大长度为50',
remote:'客户名称不能重复'
},
CustomerType: {
required: '请选择客户类型'
},
Address: {
required: '请输入地址',
maxlength: '客户名称最大长度为50'
},
OwnerId: {
required: '请选择对接人'
},
IndustryId: {
required: '请选择行业'
},
Capital: {
number: '注册资金必须为数字',
min: '注册资金最小为0.001万元',
maxlength:'注册资金最长单位为8位'
}
}
});
JQuery Validate验证显示错误提示位置的更多相关文章
- jQuery Validate验证框架详解
转自:http://www.cnblogs.com/linjiqin/p/3431835.html jQuery校验官网地址:http://bassistance.de/jquery-plugins/ ...
- 【转】jQuery Validate验证框架详解
jQuery校验官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation 一.导入js库 <script type=& ...
- jQuery Validate验证框架详解(转)
jQuery校验官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation 一.导入js库 <script type=& ...
- JQuery validate验证规则
//定义中文消息 var cnmsg = { required: “必选字段”, remote: “请修正该字段”, email: “请输入正确格式的电子邮件”, url: “请输入合法的网址”, d ...
- jQuery Validate验证框架与 jQuery ajaxSubmit的联合使用
jQuery Validate验证框架自定义验证 第一步导入导入js库 <script src="<%=basePath%>static/js/jquery.js" ...
- jQuery Validate验证框架详解(jquery.validate.min.js)
原博客 jQuery Validate验证框架详解 jQuery校验官网地址:https://jqueryvalidation.org/ 一.导入js库 <script type="t ...
- 弹出框页面中使用jquery.validate验证控件
弹出框页面中使用jquery.validate验证控件有几个问题需要解决: 1,弹出框的提交事件完成后如何关闭弹出框页面? 2,提交不成功如何返回当前页? 3,如果知道验证事件成功? 之前笔者都是JS ...
- jQuery.Validate 验证,以及 remote验证, 多参数传递
jQuery.Validate 验证: http://www.runoob.com/jquery/jquery-plugin-validate.html 教程网址,很简单, 今天主要在这里记录一下re ...
- jquery.validate验证表单配合回调提交和h5.storage本地保存笔记
表单验证插件我使用:jquery.validate.js 支持中文提示,可扩展性强!教程地址 本地保存状态信息使用:h5提供的storage,浏览器支持5m的存储量,存储类型必须是string类型,并 ...
随机推荐
- OC:属性、点语法、KVC
//属性的属性 属性定义在一个 .h文件里,在这个.h文件里可以定义实例变量(就是这个类的特征),也可以通过 @protery(属性约束关键字) 属性名字类型 属性名 来定义一些属性,在prope ...
- 去除移动端 a标签 点击有一个 阴影效果
outline: none;appearance:none; -webkit-tap-highlight-color: transparent;
- 更改SQL数据库的繁体数据为简体
上一篇说到,公司需要把所有的系统逐步更改为简体,一些系统可以保持原先的繁体数据,而有一些系统应使用部门的要求,必须要更改为简体,由于程序很大,报表也多,修改程序转换显示的可能性不大,故所以打算把数据库 ...
- 让AllocateHwnd接受一般函数地址作参数
http://www.xuebuyuan.com/1889769.html Classes单元的AllocateHWnd函数是需要传入一个处理消息的类的方法的作为参数的,原型: function Al ...
- ST10 Bootstrap Loader
Bootstrap Loader The built-in bootstrap loader (BSL) of the ST10F269 provides a mechanism to load th ...
- C# 反射类型转换
/// <summary> /// 泛型类型转换 /// </summary> /// <typeparam name="T">要转换的基础类型 ...
- 什么是双线双IP,什么叫双线双IP
双线双IP实现双线路,拥有中国电信.中国网通骨干网的接入,在该机房托管的服务器,实现了电信和网通的双线路接入,使电信和网通的用户都能以非常快的速度连接到服务器,解决了电信和网通互相访问速度慢的问题.这 ...
- MVC网站发布常见问题
直接发布的时候生成的bin会漏掉一些文件,从而导致网站无法访问: 解决方法:发布之后,再在本地运行一下网站,然后将运行后生成的bin文件夹下的文件拷贝到发布的文件夹目录下进行覆盖,就可以了
- POJ 2970 The lazy programmer(优先队列+贪心)
Language: Default The lazy programmer Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 1 ...
- linux 下cocos2dx-3.3.1环境搭建
1.安装依赖 依赖包含: libx11-dev libxmu-dev libglu1-mesa-dev libgl2ps-dev libxi-dev g++ libzip-dev libpng12-d ...