首页 > 其他分享 >elemenut的el-input限制只能输入数字

elemenut的el-input限制只能输入数字

时间:2023-04-07 17:13:55浏览次数:31  
标签:el oninput slice elemenut value replace 只能 input 输入

限制只能输入整数

关键代码:
只能输入整数: oninput="this.value = this.value.replace(/[^0-9]/g, '');"
只能输入整数且长度小于7: oninput="if( this.value.length > 7 ) {this.value = this.value.slice(0,7)} else {this.value = this.value.replace(/[^0-9]/g, '')}"
可以输入小数: oninput="this.value = this.value.replace(/[^0-9.]/g, '');"
只能输入正数: onkeyup="this.value=this.value.replace(/\D/g,'')"
只能输入正数、小数: onkeyup="this.value=this.value.replace(/[^\d.]/g,'')"
只能输入正数、小数、负数: this.value=this.value.replace(/[^-?\d.]/g,'')"

<el-input type="text" oninput="this.value = this.value.replace(/[^0-9]/g, '');" :readonly="dialog.showDetail" clearable placeholder="请填写上月表数" v-model="dialog.form.lastRecordData" @blur="computeDiffer(dialog.form.lastRecordData, dialog.form.newRecordData, 0)" @input="computeDiffer(dialog.form.lastRecordData, dialog.form.newRecordData, 0)"
                      maxlength="20"></el-input>

通过设置input类型为number类型并且限制其输入长度:oninput="if( this.value.length > 4 ) this.value = this.value.slice(0,4)"

<el-input type="number" :readonly="dialog.showDetail || dialog.status === 'detail'" placeholder="数量" v-model="scope.row.num" oninput="if( this.value.length > 4 )  this.value = this.value.slice(0,4)></el-input>

标签:el,oninput,slice,elemenut,value,replace,只能,input,输入
From: https://www.cnblogs.com/sglblog/p/16737181.html

相关文章

  • C# SQL JEXCEL 增删改查
    Handler1.ashx(用一般程序连接数据库)1<%@WebHandlerLanguage="C#"Class="Handler1"%>23usingSystem;4usingSystem.Web;5usingSystem.Data;6usingSystem.Data.SqlClient;//数据库7usingNewtonsoft.Json;//操作json库89......
  • elementui table 禁用部分多选框
    //禁用多选checkboxT(row){if(row.bomDetailParentId==0){returntrue;//禁用}else{returnfalse;//不禁用}},<el-table-columntype="selection"width="55"......
  • Shell函数
    定义[function]funName(){ action; [returnint;]}可以带functionfun()定义,也可以直接fun()定义,不加任何参数。参数返回,可以显示加return返回,如果不加,将以最后一条命令运行结果,作为返回值。return后跟的值(0-255)-----------demoFun(){echo"这是我的第一个shell函数!"}ech......
  • vue全家桶进阶之路29:Element Plus
    ElementPlus是一个用于Vue.js的UI组件库,为开发人员提供了一组可重用和可定制化的组件,用于构建现代Web应用程序。它是流行的ElementUI库的扩展,重点是提高性能和可访问性。ElementPlus包括广泛的组件,如按钮、表单、表格、对话框等。除了常规的UI组件外,ElementPlus还提供了一些......
  • StringToByte(char* source, uint8_t* dest, int sourceLen)
    voidStringToByte(char*source,uint8_t*dest,intsourceLen){inti;uint8_thighByte,lowByte;for(i=0;i<sourceLen;i+=2){highByte=toupper(source[i]);lowByte=toupper(source[i+1]);if(highB......
  • element Compressor图片压缩且上传-
      上传了压缩后的照片 <template><div><!--<el-upload:class="uploadDisabled"ref="upload":action="action":headers="headers"list-type="picture-card":limit="1":file-......
  • ASEMI代理AD8130ARZ-REEL7原装ADI车规级AD8130ARZ-REEL7
    编辑:llASEMI代理AD8130ARZ-REEL7原装ADI车规级AD8130ARZ-REEL7型号:AD8130ARZ-REEL7品牌:ADI/亚德诺封装:SOIC-8批号:2023+安装类型:表面贴装型AD8130ARZ-REEL7汽车芯片AD8130ARZ-REEL7特征高速AD8130:270兆赫,1090伏/μs@G=+1AD8129:200兆赫,1060伏/μs@G=+10高CMRR最小94dB,直流至100kH......
  • StampedLock:JDK1.8中新增,比ReadWriteLock还快的锁
    摘要:StampedLock是一种在读取共享变量的过程中,允许后面的一个线程获取写锁对共享变量进行写操作,使用乐观读避免数据不一致的问题,并且在读多写少的高并发环境下,比ReadWriteLock更快的一种锁。本文分享自华为云社区《一文彻底理解并发编程中非常重要的票据锁——StampedLock》,作者:冰......
  • Approval action add link to model driven record
    Whenyouaredecidingifyouwanttoapproveanaction,youprobablywantmoreinformationthenadescription.LuckilywecanaddalinktoourApprovalrequest!Thisisafollowuponmy previouspost whereIshowedhowtotriggeranApprovalinsideaBu......
  • Shell流程控制
    和java,php等语言不一样,sh的流程控制不可为空。1.ififthenfi-------------实例:if[$(ps-ef|grep-c"ssh")-gt1];thenechotruefi-------------ifthenelsefiifthenelifthenelsefiifelse的[]判断语句中大于使用-gt,如果使用(())作为判断语句,大于使用>2.forforvarin......