当前位置:网站首页>El input limit can only input numbers
El input limit can only input numbers
2022-06-30 08:26:00 【_ Baby grut】
el-input Limit can only enter numbers
Method 1 :
By setting type attribute :type="number"
<el-input
maxlength="11"
type="number"
v-model="ruleForm.phone"
placeholder=" Please enter contact information "
show-word-limit
></el-input>But this approach usually affects the style , Not recommended , Pictured :

Method 2 :
By binding value constraints :v-model.number="ruleForm.phone"
But this method will limit the general number , But it will affect maxlength attribute , also e It can be entered , In general, you can use , Strictly limited words are not recommended
Method 3 :
It is recommended to use
By binding value Value for regular restriction :οnkeyup="value=value.replace(/[^\d]/g, ' ')"
Bind one onkeyup Monitoring events , /[^\d]/g Is a regular expression that matches all non numeric content , Replace it with an empty string , This approach does not affect any properties
<el-input
maxlength="11"
v-model="ruleForm.phone"
placeholder=" Please enter contact information "
show-word-limit
oninput="value=value.replace(/[^\d]/g,'')"
></el-input>边栏推荐
- layer.open 当传值为数组或值太长时处理方法
- [nvme2.0b 14 - 5] commande de téléchargement / commande du logiciel
- [untitled]
- Transformer architecture understanding
- Be careful of this hole in transmittable thread local
- Cesium learning notes (V) custom geometry and appearance
- Unity简单shader
- Applet uses QR code plug-in
- [kotlin collaboration process] complete the advanced kotlin collaboration process
- This point in JS
猜你喜欢

Redis设计与实现(三)| 服务器与客户端的交互(事件IO模型)
![[nvme2.0b 14 - 5] commande de téléchargement / commande du logiciel](/img/98/bb250030f3e31e71d48e3be3ea4698.png)
[nvme2.0b 14 - 5] commande de téléchargement / commande du logiciel

1162 Postfix Expression

TiDB v6.0.0 (DMR) :缓存表初试丨TiDB Book Rush

Environment configuration of ROS Aubo manipulator

【NVMe2.0b 14】NVMe Admin Command Set

Do you know the IP protocol?

TiDB 6.0:让 TSO 更高效丨TiDB Book Rush

Redis 的过期数据如何处理,淘汰机制都有那些?
![[flower carving experience] 12 build the Arduino development environment of esp32c3](/img/76/a66e6d5c62d25067841b47eb01b718.jpg)
[flower carving experience] 12 build the Arduino development environment of esp32c3
随机推荐
Full stack performance testing theory - Summary
How to handle the expired data of redis and what are the elimination mechanisms?
Redis设计与实现(八)| 事务
【NVMe2.0b 14-6】Format NVM、Keep Alive、Lockdown command
亚马逊测评术语有哪些?
Unity simple shader
【NVMe2.0b 14-1】Abort、Asynchronous Event Request、Capacity Management command
[flower carving experience] 12 build the Arduino development environment of esp32c3
Cesium learning notes (III) creating instances
Experiment 2 LED button PWM 2021/11/15
Wechat official account third-party platform development, zero foundation entry. I want to teach you
Is it difficult to jump job ByteDance? With these skills, you can easily pass
Circuit analysis of current probe
Redis 的过期数据如何处理,淘汰机制都有那些?
Applet uses QR code plug-in
小程序使用二维码插件
Sword finger offer II 076 The kth largest number in the array (use heap to solve TOPK problem)
Redis design and Implementation (VIII) | transaction
Gilbert Strang's course notes on linear algebra - Lesson 2
JS code case