验证多个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验证显示错误提示位置的更多相关文章

  1. jQuery Validate验证框架详解

    转自:http://www.cnblogs.com/linjiqin/p/3431835.html jQuery校验官网地址:http://bassistance.de/jquery-plugins/ ...

  2. 【转】jQuery Validate验证框架详解

    jQuery校验官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation 一.导入js库 <script type=& ...

  3. jQuery Validate验证框架详解(转)

    jQuery校验官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation 一.导入js库 <script type=& ...

  4. JQuery validate验证规则

    //定义中文消息 var cnmsg = { required: “必选字段”, remote: “请修正该字段”, email: “请输入正确格式的电子邮件”, url: “请输入合法的网址”, d ...

  5. jQuery Validate验证框架与 jQuery ajaxSubmit的联合使用

    jQuery Validate验证框架自定义验证 第一步导入导入js库 <script src="<%=basePath%>static/js/jquery.js" ...

  6. jQuery Validate验证框架详解(jquery.validate.min.js)

    原博客 jQuery Validate验证框架详解 jQuery校验官网地址:https://jqueryvalidation.org/ 一.导入js库 <script type="t ...

  7. 弹出框页面中使用jquery.validate验证控件

    弹出框页面中使用jquery.validate验证控件有几个问题需要解决: 1,弹出框的提交事件完成后如何关闭弹出框页面? 2,提交不成功如何返回当前页? 3,如果知道验证事件成功? 之前笔者都是JS ...

  8. jQuery.Validate 验证,以及 remote验证, 多参数传递

    jQuery.Validate 验证: http://www.runoob.com/jquery/jquery-plugin-validate.html 教程网址,很简单, 今天主要在这里记录一下re ...

  9. jquery.validate验证表单配合回调提交和h5.storage本地保存笔记

    表单验证插件我使用:jquery.validate.js 支持中文提示,可扩展性强!教程地址 本地保存状态信息使用:h5提供的storage,浏览器支持5m的存储量,存储类型必须是string类型,并 ...

随机推荐

  1. (剑指Offer)面试题18:树的子结构

    题目: 输入两棵二叉树A和B,判断B是不是A的子结构. 二叉树结构定义如下: struct TreeNode{ int val; TreeNode* left; TreeNode* right; }; ...

  2. BOM(制造数据管理)

    --工艺路线 DECLARE -- API input variables l_operation_tbl bom_rtg_pub.operation_tbl_type := bom_rtg_pub. ...

  3. J2534 Pass-Thru Vehicle Programming ( SAE J1962 connector and Protocol )

    SAE J1962—Diagnostic Connector SAE J1850—Class B Data Communications Network Interface SAE J1939—Tru ...

  4. 查看sid

    查看用户sid: whoami /user 查看系统sid: 使用PSTools工具中的 psgetsid.exe命令查看

  5. 手游产品经理初探(六)粗糙的logo会给产品致命一击

    假设你的游戏产品从logo的设计開始就不注重细节的话,那么你的产品将不会走多远! 我们把图片放大看: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbGl1 ...

  6. 从零开始学android开发-项目重命名

    --修改项目名称 选中项目-[refactor]-[rename] --修改package名称 选中需要重命名的包-[refactor]-[rename] --修改gen下面的名称 打开Android ...

  7. Codeforces Round #290 (Div. 2) B. Fox And Two Dots dfs

    B. Fox And Two Dots 题目连接: http://codeforces.com/contest/510/problem/B Description Fox Ciel is playin ...

  8. Codeforces Educational Codeforces Round 3 B. The Best Gift 水题

    B. The Best Gift 题目连接: http://www.codeforces.com/contest/609/problem/B Description Emily's birthday ...

  9. Apache的Order Allow Deny心得

    Allow和Deny可以用于apache的conf文件或者.htaccess文件中(配合Directory, Location, Files等),用来控制目录和文件的访问授权. 所以,最常用的是: O ...

  10. Handler具体解释

    首先下载Android api 进行查阅 ,API下载地址:http://pan.baidu.com/s/1i33dTGT 以下的描写叙述假设那里错了,请大家吐槽,我也是第一次学习,共同进步 Hand ...