<input class="uni-input iptStyle" name="input" placeholder="未识别出信息" v-model="form.fpNum" @input="fpNumInput" maxlength='24' /> const inputRule = /^(0+)|[^\d]+/g //修改inputRule 的值 this.$nextTick(function() { this.form.fpNum = o.value.replace(inputRule , '');
1.只能输入数字
const inputRule = /[^\d]/g
2.只能输入字母
const inputRule = /[^a-zA-Z]/g
3.只能输入数字和字母
const inputRule =/[\W]/g
4.只能输入小写字母
const inputRule =/[^a-z]/g
5.只能输入大写字母
const inputRule =/[^A-Z]/g
6.只能输入数字和字母和下划线
const inputRule =/[^\w_]/g //下划线也可以改成%
7.只能输入中文
const inputRule =/[^\u4E00-\u9FA5]/g
8.只能输入数字和小数点
const inputRule =/[^\d.]/g
9.验证手机号是否正确
var strTemp = /^1[3|4|5|6|7|8|9][0-9]{9}$/; uni.showToast({icon:'none',title:'请输入正确的电话'});
10. 电话号码隐藏中间4位
var phonenumber=15054054532; var reg = /^(\d{3})\d{4}(\d{4})$/; this.phonenum=phonenumber.replace(reg, "$1****$2")
转载:感谢分享 原文链接:https://blog.csdn.net/x_XDGS/article/details/120996210
|