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类型,并 ...
随机推荐
- PowerDesigner 业务处理模型( BPM ) 说明 及Enterprise Architect使用教程
http://www.cnblogs.com/springside-example/archive/2011/10/17/2529640.html http://wenku.baidu.com/lin ...
- 通过SimpleAction显示一个listview
private void simpleAction1_Execute(object sender, SimpleActionExecuteEventArgs e) { IObjectSpace os ...
- Hadoop集群基准测试
hadoop jar ./share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.2.0-tests.jar TestDFSIO -wri ...
- js面向对象,有利于复用
需求:在网页上添加个天气预报. 以前总是在需要执行js的地方,直接写function(){}.在需要同样功能的地方直接copy,或者稍微修改. 然后在网上看看有没有好点的方法,然后就看到js面向对象编 ...
- 永久改动redhat的default route
1,能够用route命令暂时改动: route add default gw <gateway ip> 2, 通过改动/etc/sysconfig/network 文件永久改动: 脚本: ...
- Codeforces 427 D. Match & Catch
后缀数组.... 在两个串中唯一出现的最小公共子串 D. Match & Catch time limit per test 1 second memory limit per test 51 ...
- TCP/IP协议族-----13、运输层简单介绍
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaGVrZXdhbmd6aQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQk ...
- C++异常
相对于C语言,C++增加了异常机制.考虑,异常解决了什么问题,又带来了什么问题. 异常解决了什么问题: 1.问题检测与问题处理相分离. 2.C语言只是返回一个整数,而异常带有上下文信息,方便找出问题. ...
- Codeforces Round #339 (Div. 2) B. Gena's Code 水题
B. Gena's Code 题目连接: http://www.codeforces.com/contest/614/problem/B Description It's the year 4527 ...
- Java学习笔记(4)——JavaSE
一.HashMap HashMap以键值对的形式存储对象,关键字Key是唯一的,不重复的 1,key可以是任何对象,Value可以任何对象 2,重复的key算一个,重复添加是替换操作(会覆盖原来的元素 ...