您的位置:首页 > Web前端 > JQuery

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属性。

这样就可以了。

                                            -------------每天进步一点。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: