el-input 限制输入框只能输入数字和小数
方法一:
oninput =“value=value.replace(/[^\d]/g,‘’)” //只能输入数字
oninput =“value=value.replace(/[^0-9.]/g,‘’)” //只能输入数字和小数
<el-input v-model="sjje" oninput ="value=value.replace(/[^0-9.]/g,'')" class="money sjje">
<span slot="suffix">/ 元 </span>
</el-input>
方法二:
<el-input v-model="sjje" class="money sjje" @input="inputChange">
<span slot="suffix">/ 元 </span>
</el-input> inputChange(val) {
this.sjje = this.sjje.replace(/[^0-9.]/g, '')
}
2、form表单输入框
<el-form ref="userform" rules="rules" :model="form" label-width="110px">
<el-row>
<el-form-item label="年龄:" prop="age">
<el-input v-model="form.age"></el-input>
</el-form-item>
</el-row>
</el-form> rules:{
age:[
{ required: true, message: '年龄不能为空', trigger: 'blur'},
{pattern: /^[0-9]*$/, message: '年龄需为数字', trigger: 'blur'}
]
},
来源于:https://blog.csdn.net/weixin_44171757/article/details/102391297
el-input 限制输入框只能输入数字和小数的更多相关文章
- input输入框只能输入数字和 小数点后两位
//input输入框只能输入数字和 小数点后两位 function num(obj,val){ obj.value = obj.value.replace(/[^\d.]/g,"" ...
- 控制input标签中只能输入数字以及小数点后两位
js 代码如下: /* 控制input标签中只能输入数字 和小数点后两位 */ function checkNum(obj) { //检查是否是非数字值 if (isNaN(obj.value)) { ...
- Html限制input输入框只能输入数字
限制输入框只能输入数字, onafterpaste防止用户从其它地方copy内容粘贴到输入框: <input type="text" onkeyup="this.v ...
- JS实现输入框只能输入数字
键盘下落事件实现输入框只能输入数字: <script type="text/javascript"> // 实现输入框只能输入数字 function ValidateN ...
- js限制输入框只能输入数字
分享下js限制输入框中只能输入数字的方法,包括整数与小数,分享几个例子,有需要的朋友参考下. 1.使用正则表达式限制输入框只能输入数字: <input type="text" ...
- JS通过正则限制 input 输入框只能输入整数、小数(金额或者现金)
第一: 限制只能是整数 <input type = "text" name= "number" id = 'number' onkeyup= " ...
- 通过javascri实现输入框只能输入数字
输入框只能输入数字 <input type="text" onkeyup="value=value.replace(/[^\d]/g,'');"> ...
- 限定输入框只能输入数字, TextBox的TextChanged事件调用
/// <summary> /// 限定输入框只能输入数字, TextBox的TextChanged事件调用 /// </summary> /// <param name ...
- input输入框 只能输入数字 oninput = "value=value.replace(/[^\d]/g,'')" input输入框输入大于0的数字 oninput="value=value.replace(/\D|^0/g,'')"
项目中因为利用 element-ui 和avue两个ui框架搭建的 1.利用element-ui自带的校验需要注意点 prop :rules ref这三个属性 2.利用oninput时间进行校验 ...
- input 输入框 只能输入数字、字母、汉字等
1.文本框只能输入数字代码(小数点也不能输入) <input onkeyup="this.value=this.value.replace(/\D/g,'')" onafte ...
随机推荐
- git提交到代码到远程仓库,合并分支提示entirely different commit histories(备忘)
最近提交代码到github,合并分支的时候提示"master and main are entirely different commit histories" master为本地 ...
- 青少年CTF-从尾看到头[WP]
一 题目描述 二 解题步骤 2.1第一层压缩包 压缩包打开提示出错 010editor中观察文件格式,文件尾明显观察到是正常压缩包的逆序,考虑逆序读取生成一个新的zip python代码 with o ...
- MongoDB升级
因业务需要所以需要对mongoDB客户端jar包升级,在此记录一些过程 1.jar包替换,引入依赖 3.2.2: mongo-java-driver | 4.6.1: mongo-dr ...
- 通过java代码向mysql数据库插入记录,中文乱码处理
处理步骤 修改mysql配置文件,并重启mysql服务.mysql默认配置文件路径为/etc/my.cnf. 修改配置如下: [mysqld] character-set-server=utf8 [c ...
- 蓝牙mesh组网实战(智能家居应用)
目录 蓝牙mesh组网目前存在有入门门槛高的问题,比如,嵌入式工程师需要考虑到标准mesh模型的兼容,app开发工程师需要了解mesh协议栈才能直接走mesh与芯片通信.而沁恒官方提供的透传模型简洁易 ...
- vux方法
vuex 的备注 // vuex的公用数据放置处 state: { count: 0, }, // (方法) 在里面可以去修改state里面的数据(在这里面不能写异步操作) mutations: { ...
- Usage of Seven Zip in C#
Compresss by Squid-Box.SevenZipSharp.Lite choose x86/x64 7z dll if (IntPtr.Size == 4) { SevenZipExtr ...
- 关于.bashrc文件
文件作用 存储临时变量 注意 每个user都有自己的.bashrc文件,root用户也有. 普通用户在"/home/username/"目录下 root在"/root&q ...
- 使用Wireshark完成实验3-IP
1.使用Wireshark打开ip-ethereal-trace-1,如图 电脑IP地址为192.168.1.102 2.如图,IP包头中上层协议字段的值为1,代表为ICMP 3.如图,IP头中有20 ...
- Java基础学习:4、类和对象及方法
类:事物的描述.是具备某些共同特征的实体的集合,它是一种抽象的数据类型,它是对所具有相同特征实体的抽象. 对象:该类事物的实例.在Java中通过new进行创建.是一个真实世界中的实体.对象是一种个性的 ...