js变态需求

 //手机号格式 3-4-4 不验证手机号码:
    Mobile_input(type){
      if(type === "recvMobile"){
        var value = this.erp_register_msg.recvMobile;
      }else if(type === "fapiaoRecvMobile"){
        var value = this.erp_register_msg.fapiaoRecvMobile;
      }
      value = value.replace(/[^0-9]/ig, ""); 
      var arr = value.split('');
      if (arr.length >= 4) {
        arr.splice(3, 0, ' ');
      } 
      if (arr.length >= 9) {
        arr.splice(8, 0, ' ');
      }
      value = arr.join('');

     if(type === "recvMobile"){
        this.erp_register_msg.recvMobile = value;
      }else if(type === "fapiaoRecvMobile"){
        this.erp_register_msg.fapiaoRecvMobile = value;
      }

    },
    //不能输中文
    chinaese_input(){
      this.erp_register_msg.creditCode = this.erp_register_msg.creditCode.replace(/[\u4E00-\u9FA5]|[\uFE30-\uFFA0]/g,''); 
    },
    //不能输入中文和字母
    limt_chinaese_english(){
      this.erp_register_msg.phone=this.erp_register_msg.phone.replace(/[\u4E00-\u9FA5]|[A-Za-z]/g,'');
    },
    //只能输入数字
    limt_number(){
       this.erp_register_msg.bankAccount = this.erp_register_msg.bankAccount.replace(/[^\d]/g,'');
    }

 

posted @ 2020-09-16 14:24  Action_swt  阅读(252)  评论(0编辑  收藏  举报