当前位置:网站首页>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>边栏推荐
- 2021-04-29
- 【NVMe2.0b 14-6】Format NVM、Keep Alive、Lockdown command
- Circuit analysis of current probe
- Opencv image
- Gilbert Strang's course notes on linear algebra - Lesson 4
- 2021-02-19
- 一次cpu 跌底排查
- QT event cycle
- Common tools installation, configuration, compilation, link, etc
- Want to ask, how to choose securities companies for stock speculation? Is it safe to open an account online?
猜你喜欢

云服务器上部署仿牛客网项目

亚马逊测评术语有哪些?

Axure制作菜单栏效果

How to handle the expired data of redis and what are the elimination mechanisms?

Deploy the cow like customer network project on the ECS

How CRM & PM helps enterprises create optimal sales performance

el-input 限制只能输数字

【NVMe2.0b 14-7】Set Features(上篇)

微信小程序使用vant weapp报错

电流探头电路分析
随机推荐
[tensorflow GPU] building of deep learning environment under windows11
layer.open 当传值为数组或值太长时处理方法
el-input 限制只能输数字
C# Console. Writeline() function output format
牛客小白月賽52
MySQL quotation sentence is unlocked: algorithm=insert, lock=none
[notes] polygon mesh processing learning notes (10)
Wechat official account third-party platform development, zero foundation entry. I want to teach you
[flower carving experience] 13 build the platformio ide development environment of esp32c3
Final review -php learning notes 2-php language foundation
Circuit analysis of current probe
电流探头电路分析
Construction of energy conservation supervision system for campus buildings of ankery University
【NVMe2.0b 14-5】Firmware Download/Commit command
C preliminary chapter learning route
Game 280 problem2: minimum operands to turn an array into an alternating array
Experiment 2 LED button PWM 2021/11/22
Introduction to opencv (II): image color space conversion and image saving
How to handle the expired data of redis and what are the elimination mechanisms?
Dart tips