ID verification, mobile phone number verification, digital verification

<1> ID verification  

    <tr height="50px;">

            <td class="textDiv" width="30%" style="padding-left: 10px;color: #646464;">身份证号:</td>

            <td class="textDiv" width="70%"><input type="text" maxlength="18" class="inputCss" id="idcard" name="idcard" placeholder="请输入身份证号"></td>

    </tr>

、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、

    var idcard = $("#idcard").val();

、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、

    /* ID verification */

     var reg=/^[1-9]{1}[0-9]{14}$|^[1-9]{1}[0-9]{16}([0-9]|[xX])$/;

     if(!reg.test(idcard)){

        alert2("Your ID is wrong!!!");

  return false;

     }

、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、

 <2> Mobile phone number verification

    <tr height="50px;">

            <td class="textDiv" width="30%" style="padding-left: 10px;color: #646464;">手机号:</td>

            <td class="textDiv" width="70%"><input type="text" maxlength="11" id="mobile" name="mobile" class="inputCss"  placeholder="请输入手机号"></td>

    </tr>

  、、、、、、、、、、、、、、、、、、、、、、

     var mobile = $("#mobile").val();

 、、、、、、、、、、、、、、、、、、、、、、、、

     /* phone number check */

     if(mobile.length != 11){

      alert2("The phone number you entered is incorrect!!!");

      return;

      }

      var myreg = / ^ (((13 [0-9] {1}) | (15 [0-9] {1}) | (18 [0-9] {1})) + \ d {8}) $ /; 

      if(!myreg.test($("#mobile").val())) 

      { 

         alert2('Please enter a valid mobile number!'); 

          return false; 

       }

  、、、、、、、、、、、、、、、、、、、、、

<3> Numerical verification (only numbers can be entered, not Chinese characters)

   <tr height="50px;">

      <td class="textDiv" width="30%" style="padding-left: 10px;color: #646464;">意向金额:</td>

      <td class="textDiv" width="70%">

      <input type="text" id="totalfee" class="inputCss" maxlength="4" style="width: 100px;" name="totalfee"  placeholder="请输入费用">元

       </td>

   </tr>

 

  /* Verify the intention amount */

      $(function(){ 

   $("#totalfee").digitLimit();

});

    、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、

    $.fn.digitLimit = function() {  

    $(this).css("ime-mode", "disabled"); 

    var mozilla = /firefox/.test (navigator.userAgent.toLowerCase ());

    var webkit = /webkit/.test (navigator.userAgent.toLowerCase ());

    var opera = /opera/.test (navigator.userAgent.toLowerCase ());

    var msie = /msie/.test (navigator.userAgent.toLowerCase ());

    this.bind("keypress",function(e) {  

    var code = (e.keyCode? e.keyCode: e.which); // and Firefox IE 

    if(mozilla && (e.keyCode==0x8)) //The backspace key cannot be used under Firefox  

        {  

             return ;  

        }  

    if (code == 46) {

if (this.value.indexOf(".") != -1) {

return false;

}

} else{

return code >= 48 && code<= 57;   

}   

    });  

    this.bind("blur", function() {  

        if (this.value.lastIndexOf(".") == (this.value.length - 1)) {  

            this.value = this.value.substr(0, this.value.length - 1);  

        } else if (isNaN(this.value)) {  

            this.value = "";  

        } 

    });  

    this.bind("paste", function() {  

        var s = clipboardData.getData('text');  

        if (!/\D/.test(s));  

        value = s.replace(/^0*/, '0');  

        return false;  

    });  

    this.bind("dragenter", function() {  

        return false;  

    });  

    this.bind("keyup", function() {  

    if (/(^0+)/.test(this.value)) {  

        this.value = this.value.replace(/^0*/, '0');  

        }  

    });  

};




 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326175634&siteId=291194637