el-input-input表单验证
时间: 2023-10-07 19:13:36 浏览: 110
el-input表单验证可以通过设置v-model.number属性为true来限制输入为数字。同时,可以使用input事件结合字符串的replace()方法将非数字的内容替换为空,这样就只能输入正整数了。例如:
```
<el-input v-model.number="val" type="tel" @input="val = val.replace(/[^\d]/g,'')" />
```
这样设置后,输入框只能输入数字,并且非数字的内容会被替换为空。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [设置输入框el-input图标 / el-input表单只显示number](https://blog.csdn.net/m0_53912016/article/details/126606802)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *3* [el-input自定义表单验证](https://blog.csdn.net/qq_59076775/article/details/125030042)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文