jquery Validate
2015-07-11 11:28
645 查看
1、首先在jsp页面引入<script type="text/javascript" src="${ctx}/js/simpleValidate.js"></script>文件,${ctx}代表项目下的WEB-INF路径,只要正确引入即可。
2、在jsp页面总写入js函数
function formValidate(){
$("#account_formDiv").validate({
rules : {
"ent.accountName" : {
required : true
},
"ent.accountspell" : {
required : true
},
"ent.idNumber" : {
required : true
},
"ent.phonenum" : {
required : true
},
"ent.address" : {
required : true
},
"ent.protocolId" : {
required : true
}
},
messages : {
"ent.accountName" : {
required : "请输入客户名称"
},
"ent.accountspell" : {
required : "请输入客户拼音"
},
"ent.idNumber" : {
required : "请输入身份证号"
},
"ent.phonenum" : {
required : "请输入手机号码"
},
"ent.address" : {
required : "请输入联系地址"
},
"ent.protocolId" : {
required : "请选择费率协议"
}
}
});
}
其中ent.accountName代表<td><s:textfield name="ent.accountName" cssClass="" onchange="changeToPinyin(this.value);"/></td>中的name属性。
这样就可以了。
-------------每天进步一点。。
2、在jsp页面总写入js函数
function formValidate(){
$("#account_formDiv").validate({
rules : {
"ent.accountName" : {
required : true
},
"ent.accountspell" : {
required : true
},
"ent.idNumber" : {
required : true
},
"ent.phonenum" : {
required : true
},
"ent.address" : {
required : true
},
"ent.protocolId" : {
required : true
}
},
messages : {
"ent.accountName" : {
required : "请输入客户名称"
},
"ent.accountspell" : {
required : "请输入客户拼音"
},
"ent.idNumber" : {
required : "请输入身份证号"
},
"ent.phonenum" : {
required : "请输入手机号码"
},
"ent.address" : {
required : "请输入联系地址"
},
"ent.protocolId" : {
required : "请选择费率协议"
}
}
});
}
其中ent.accountName代表<td><s:textfield name="ent.accountName" cssClass="" onchange="changeToPinyin(this.value);"/></td>中的name属性。
这样就可以了。
-------------每天进步一点。。
相关文章推荐
- 【HTML/JS】利用JQuery的load函数动态加载其它页面的内容的实现代码
- jquery 创建遮盖层 示例代码
- 移动开发必备!15款jQuery Mobile插件
- Jquery 对新插入的节点 绑定Click事件失效
- JQuery在Ajax的Post提交中国乱码的解决方案
- jquery ui 笔记
- jQuery缓存操作-cache数据
- jQuery第二弹强大的选择器
- jquery ui动态切换主题的一种实现方式
- jquery实现图片上传之前预览的方法
- JQuery 设置元素的高度和宽度相等
- JQuery入门——进度条
- jQuery源码之ready()事件
- jQuery.form Ajax无刷新上传错误 (jQuery.handleError is not a function) 解决方案
- jquery 完成checkbox的全选功能
- jquery 对 Json 的各种遍历
- jquery.ajax提交多值(数组)
- jQuery 选择器
- 黑马day16 子jquery&子元素过滤选择器
- jquery ajax参数加点号状态200进error