zoukankan      html  css  js  c++  java
  • input 输入金额正则判断

       <input
              pattern="d*"
              type="tel"
              onkeyup="this.value=this.value.replace(/[^d.]/g,'');"
              keyboardType="UIKeyboardTypeDecimalPad;"
              v-model="value"
              class="home-payment-input"
              @input="checkInput"
            />
       
     
     
     
    checkInput() {
          this.value = this.dealInputVal(this.value);
        },
        dealInputVal(value) {
          value = value.replace(/^0*(0.|[1-9])/, "$1");
          value = value.replace(/[^d.]/g, ""); //清除"数字"和"."以外的字符
          value = value.replace(/^./g, ""); //验证第一个字符是数字而不是字符
          value = value.replace(/.{1,}/g, "."); //只保留第一个.清除多余的
          value = value
            .replace(".", "$#$")
            .replace(/./g, "")
            .replace("$#$", ".");
          value = value.replace(/^(-)*(d*).(dd).*$/, "$1$2.$3"); //只能输入两个小数
          value =
            value.indexOf(".") > 0
              ? value.split(".")[0].substring(0, 10) + "." + value.split(".")[1]
              : value.substring(0, 10);
              if(value == ""){
                this.disabled = true;
              }else if(value == Number(0)){
                this.disabled = true;
              }else if(value == "0."){
                 this.disabled = true;
              }else{
                this.disabled = false;
              }
          return value;
        }
  • 相关阅读:
    22_selenium_使用cookie直接登录
    21_无头模式
    自动化测试-设计模式-介绍
    Doorls
    pytest-Allure报告
    pytest-架构1
    pytest-第一次学习梳理
    web测试
    测试-工时评估
    封装pyuic5转换ui文件的脚本
  • 原文地址:https://www.cnblogs.com/1609359841qq/p/13072331.html
Copyright © 2011-2022 走看看