validformバインドイベント

42514 ワード

//    <script type="text/javascript" src="js/Validform_v5.3.2_min.js"></script> // jsp   <form class="healthForm" action="" method="post">

    <div>

        <div class="ps_center_hang">

            <input type="hidden" name="clientInfo.id" value="${clientId}"/>

            <b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>

            <input type="text" size="12" class="ps_center_input_bd" name="clientInfo.name" value="${clientInfo.name}"/>

            &nbsp;&nbsp;<b></b>

            <s:radio list='#{ "0":" ","1":" "}' name="clientInfo.gender" value="clientInfo.gender" />

            <span style="padding-left:90px;">

                <b>&nbsp;</b>

                <!--<span id="birthday"></span>-->

                <input type="text" name="clientInfo.birthday" id="sDate"  class="ps_center_input_bd" value='<fmt:formatDate value="${clientInfo.birthday}"  pattern="yyyy-MM-dd"/>' onclick="" readonly="readonly"/>

            </span>

        </div>

        <div class="ps_center_hang">

            <b></b>

            <input type="text" size="30" class="ps_center_input_bd" name="clientInfo.idCards" value="${clientInfo.idCards}"/>

            <span style="padding-left:60px;"><b>&nbsp;&nbsp; &nbsp;&nbsp;</b>

                <span id="birthPlace"></span>

            </span>

        </div>

        <div class="ps_center_hang">

            <b> &nbsp;&nbsp; &nbsp;&nbsp;</b>

            <input type="text" size="30" class="ps_center_input_bd" name="clientInfo.usualAddress" value="${clientInfo.usualAddress}"/>

            <span style="padding-left:60px;">

                <b>&nbsp;&nbsp; &nbsp;&nbsp;</b>

                <input type="text" size="30" class="ps_center_input_bd" name="clientInfo.ethnic" value="${clientInfo.ethnic}"/>

            </span>

        </div>

        <div class="ps_center_hang">

            <b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>

            <input type="text" size="85" class="ps_center_input_bd" name="clientInfo.faith" value="${clientInfo.faith}"/>

        </div>

        <div class="ps_center_hang">

            <b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>

            <s:radio list='#{ "1":"A","2":"B","3":"O","4":"AB","5":"  "}' name="clientInfo.bloodType" value="clientInfo.bloodType" />

            <span style="padding-left:150px;"><b>RH  :</b>

                <s:radio list='#{ "1":" ","2":" ","3":"  "}' name="clientInfo.rh" value="clientInfo.rh" />

            </span>

        </div>

        <div class="ps_center_hang">

            <b></b>

            <s:radio list='#{ "1":"    ","2":"  ","3":"  ","4":"   /   ","5":"   /    ","6":"     "}'

                name="clientInfo.culture" value="clientInfo.culture" />

        </div>

        <div class="ps_center_hang">

            <b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>

            <s:checkboxlist name="professions"

                list="#{'1':'  ','2':'  ','3':'  ','4':'  ','5':'  ','6':'  ','7':'  ','8':'  ','9':'  ','10':'  ','11':'  ','12':'  '}"

                listKey="key" listValue="value"></s:checkboxlist>

        </div>

        <div class="ps_center_hang">

            <b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>

            ( / )<s:radio list="#{'1':'  1000','2':'1000-2000','3':'2000-3000','4':'3000-4500','5':'4500-6000','6':'6000-10000','7':'  10000'}"

                        name="clientInfo.income" value="clientInfo.income"></s:radio>

        </div>

        <div class="ps_center_hang">

            <b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>

            <s:radio list="#{'1':'  ','2':'  ','3':'  ','4':'  ','5':'  '}"

                name="clientInfo.marriage" value="clientInfo.marriage"></s:radio>

        </div>

        <div class="ps_center_hang">

            <b></b>

            <input type="text" size="28" class="ps_center_input_bd" name="clientInfo.workUnits" value="${clientInfo.workUnits}"/>

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>

            <input type="text" size="10" class="ps_center_input_bd" name="clientInfo.duty" value="${clientInfo.duty}"/>

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b></b>

            <input type="text" size="10" class="ps_center_input_bd" name="clientInfo.unitsPhone" value="${clientInfo.unitsPhone}"/>

        </div>

        <div class="ps_center_hang">

            <b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>

            <input type="text" size="28" class="ps_center_input_bd" name="clientInfo.address" value="${clientInfo.address}"/>

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b></b>

            <input type="text" size="10" class="ps_center_input_bd" name="clientInfo.phone" value="${clientInfo.phone}"/>

            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b></b>

            <input readonly="readonly" type="text" size="10" class="ps_center_input_bd" name="clientInfo.mobile" value="${clientInfo.mobile}"/>

        </div>

        <div class="ps_center_hang">

            <b></b>

            <s:radio list="#{'1':'  ','2':'    ','3':'  ','4':'  '}" name="clientInfo.medicalExpenses"

                value="clientInfo.medicalExpenses"></s:radio>

        </div>

    </div>

    <div class="clear"></div>

    <input type="button" value="  " class="ps_center_button" id="saveHealth"/>

</form>
// js  

$(function () {

    validate();//

})



/**

 *     

 */

function validate() {

    $.Tipmsg.r = null;

    var showmsg = function (msg) {

        alert(msg);

    }

    var laf = $(".healthForm").Validform({

            btnSubmit : "#saveHealth",

            tiptype : function (msg) {// tiptype   1、2        

                showmsg(msg);//     

            },

            tipSweep : true,

            postonce : true

        });



    //        

    $.extend(

        $.Datatype, {

        "s0-64" : function (val) {// 0-64     

            if ("" != val) {

                var pattern = /^[\w\W]{0,64}$/;

                if (!pattern.test(val)) {

                    return false;

                }

            }

        },

        "email" : function (val) {//     

            if ("" != val) {

                var pattern = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;

                if (!pattern.test(val)) {

                    return false;

                }

            }

        },

        "s0-32" : function (val) {// 0-32     

            if ("" != val) {

                var pattern = /^[\w\W]{0,32}$/;

                if (!pattern.test(val)) {

                    return false;

                }

            }

        },

        "s0-255" : function (val) {//     

            if ("" != val) {

                var pattern = val.length;

                if (pattern > 225) {

                    return false;

                }



            }

        },

        "idCards" : function (val) {//      

            if ("" != val) {

                var pattern = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;

                if (!pattern.test(val)) {

                    return false;

                }

            }

        },

        "phones" : function (val) {//      

            if ("" != val) {

                var pattern = /(^[0-9]{3,4}[0-9]{7,8}$)|(^[0-9]{7,8}$)|(^[0-9]{3,4}\-[0-9]{7,8}$)|(^[0-9]{7,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/;

                if (!pattern.test(val)) {

                    return false;

                }

            }

        },

        "sex" : function () {//     

            var l = $(":input[name='clientInfo.gender']:checked").length;

            if (l <= 0) {

                return false;

            }

        },

        "birthday" : function () {

            var y = $(":input[name='clientInfo.birthday']").val();

            if ("" == y || null == y) {

                return false;

            }

        }

    });



    laf.addRule([{

                ele : ":input[name='clientInfo.clientCode']",//   input  ,  #xx

                datatype : "s0-64",

                nullmsg  : "    ",//

                errormsg : "               64"//     

            }, {

                ele : ":input[name='clientInfo.name']",

                datatype : "s0-64",

                nullmsg  : "    ",//

                errormsg : "         64"//     

            }, {

                ele : ":input[name='clientInfo.gender']",

                datatype : "sex",

                nullmsg : "        ",

                errormsg : ""

            }, {

                ele : ":input[name='clientInfo.birthday']",

                datatype : "birthday",

                nullmsg : "            !",

                errormsg : ""

            }, {

                ele : ":input[name='clientInfo.email']",

                datatype : "email",

                errormsg : "        "

            }, {

                ele : ":input[name='clientInfo.ethnic']",

                datatype : "s0-32",

                errormsg : "         32"

            }, {

                ele : ":input[name='clientInfo.faith']",

                datatype : "s0-255",

                errormsg : "         225"

            }, {

                ele : ":input[name='clientInfo.idCards']",

                datatype : "idCards",

                errormsg : "           "

            }, {

                ele : ":input[name='clientInfo.usualAddress']",

                datatype : "s0-255",

                errormsg : "          225"

            }, {

                ele : ":input[name='clientInfo.workUnits']",

                datatype : "s0-255",

                errormsg : "           225"

            }, {

                ele : ":input[name='clientInfo.duty']",

                datatype : "s0-64",

                errormsg : "         64"

            }, {

                ele : ":input[name='clientInfo.address']",

                datatype : "s0-255",

                errormsg : "         225"

            }, {

                ele : ":input[name='clientInfo.phone']",

                datatype : "phones",

                errormsg : "          "

            }, {

                ele : ":input[name='clientInfo.unitsPhone']",

                datatype : "phones",

                errormsg : "          "

            }

        ]);



}

加群QQ 226728216