• input的onkeyup


    onkeyup="this.value = this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''"
    正数,保留两位小数


    onkeyup="this.value = this.value.match(/\-?(\d+(\.\d{0,2})?)?/) ? this.value.match(/\-?(\d+(\.\d{0,2})?)?/)[0] : ''"
    支持负数,保留两位小数


    onkeyup="this.value = this.value.match(/(\-{0,1}\d{0,8})?/) ? this.value.match(/(\-{0,1}\d{0,8})?/)[0] : ''"
    支持负数,8位整数


    onkeyup="this.value = this.value.replace(/\D|^0/g,'')"
    大于0的正整数


    onkeyup="this.value = this.value.replace(/\D/g,'')"
    包括0的正整数


    $("#Price").textbox('textbox').bind('keyup', function (e) {
      $("#Price").textbox('setValue', $(this).val().match(/\d+(\.\d{0,2})?/) ? $(this).val().match(/\d+(\.\d{0,2})?/)[0] : '' );
    });
    easyui用法

    onkeyup="this.value = this.value.replace(/[,,]/g,'')
    去除中英文逗号


    onkeyup="this.value = this.value.match(/([\(\)\u4E00-\u9FA5]{0,30})/) ? this.value.match(/([\(\)\u4E00-\u9FA5]{0,30})/)[1] : ''"
    只能输入中文30个字以内


    onkeyup="this.value = this.value.match(/(\d{1,11})/) ? this.value.match(/(\d{1,11})/)[0] : ''"
    11位数字


    onkeyup="this.value = this.value.match(/([a-zA-Z0-9]{0,16})/) ? this.value.match(/([a-zA-Z0-9]{0,16})/)[0] : ''"
    16位数字和字母包括大小写

    <input class="ACDInp1 wzr" type="number" min="0" v-model="item.creditLine" v-on:focus="clear(1,item.creditLine,index)" v-on:blur="myBlur(item.creditLine,index)" onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''">
    myBlur:function(val,ind){
    if(val === ''){
    this.list2[ind].creditLine = 0
    }else{
    this.list2[ind].creditLine = val.match(/\d+(\.\d{0,2})?/) ? val.match(/\d+(\.\d{0,2})?/)[0] : ''
    }
    },
    在vue中使用要注意v-model双向绑定的值在blur时需要再执行一次,否则键入的小数点后第三位不会被真正清除
  • 相关阅读:
    win10 uwp 异步进度条
    win10 uwp 异步进度条
    win10 uwp 简单MasterDetail
    win10 uwp 简单MasterDetail
    如何使用PHP验证客户端提交的表单数据
    PHP 表单和用户输入讲解
    什么是PHP 面向对象
    PHP 命名空间(namespace)定义
    PHP 魔术常量介绍
    archer 安装
  • 原文地址:https://www.cnblogs.com/liufeiran/p/16206511.html
Copyright © 2020-2023  润新知