zoukankan      html  css  js  c++  java
  • 常用的一些正则验证

    //input点击控制
    function hiddenPrompt(text, id) {
        if ($("#" + id).val() == text) {
            $("#" + id).val("");
        }
    }
    // input焦点离开控制
    function showPrompt(text, id) {
        if ($("#" + id).val() == "") {
            $("#" + id).val(text);
        }
    }
    /*手机号为11位*/
    function checkCardId(strReserveMobile){
        var strReserveMobileReg= /^d{11}$/;
        if(!strReserveMobileReg.test(strReserveMobile)){
            info("请输入正确的手机号");
            return false;
        }
    }
    /*银行卡必须是16位到19位数字*/
    function checkBankcard(strBankcardNo){
        var strBankcardNoReg= /^(d{16}|d{19})$/;
        if(!strBankcardNoReg.test(strBankcardNo)){
            info("请输入正确的银行卡号");
            return false;
        }
    }
    /*身份证件号必须是18位;如果为18位,前17位必须是数字,后1位为数字或者x*/
    function checkIdentity(strIdentity){
        var strIdentityReg=/^d{18}$|^d{17}(d|X|x)$/;
            if(strIdentityReg.test(strIdentity)){
               var strIdentityEnd=strIdentity.substring(17,18);
               if(strIdentityEnd=="x"){
                    strIdentity=strIdentity.replace('x','X');
               }
            }else{
                info("请输入正确的身份证件号");
                return false;
            }
    }
    /*去除空格*/
    function Trim(str){ 
        return str.replace(/(^s*)|(s*$)/g, ""); 
    }
    记下点滴,等老了慢慢欣赏
  • 相关阅读:
    算法训练——整数平均值
    算法训练——字符删除
    算法训练——最大的算式
    flask_sqlalchemy查询时将date类型修改为datetime类型
    mysql更改时区
    python 省略号 三个点...的含义
    ubuntu系统安装gedit
    python操作hdfs总结
    流式上传下载
    python将文件夹打包
  • 原文地址:https://www.cnblogs.com/binmengxue/p/5287488.html
Copyright © 2011-2022 走看看