input框常用的正則表達式
<input class=“uni-input iptStyle” name=“input” placeholder=“未識別出信息” v-model=“form.fpNum” @input=“fpNumInput” maxlength=‘24’ />
fpNumInput(e) {
const o = e.target;
const inputRule = /(0+)|[\d]+/g //修改inputRule 的值
this.$nextTick(function() {
this.form.fpNum = o.value.replace(inputRule , ‘’);
})
},
1.只能輸入數(shù)字
const inputRule = /[^\d]/g
2.只能輸入字母
const inputRule = /[^a-zA-Z]/g
3.只能輸入數(shù)字和字母
const inputRule =/[\W]/g
4.只能輸入小寫字母
const inputRule =/[^a-z]/g
5.只能輸入大寫字母
const inputRule =/[^A-Z]/g
6.只能輸入數(shù)字和字母和下劃線
const inputRule =/[^\w_]/g //下劃線也可以改成%
7.只能輸入中文
const inputRule =/[^\u4E00-\u9FA5]/g
8.只能輸入數(shù)字和小數(shù)點
const inputRule =/[^\d.]/g
驗證手機號是否正確
var phone=15054054532;
var strTemp = /^1[3|4|5|6|7|8|9][0-9]{9}$/;
if(strTemp.test(phone)){
console.log(“正確”)
}else{
uni.showToast({icon:‘none’,title:‘請輸入正確的電話’});
return false
}
電話號碼隱藏中間4位
var phonenumber=15054054532;
var reg = /^(\d{3})\d{4}(\d{4})$/;
this.phonenum=phonenumber.replace(reg, “$1****$2”)文章來源:http://www.zghlxwxcb.cn/news/detail-435463.html
轉載:感謝分享
原文鏈接:https://blog.csdn.net/x_XDGS/article/details/120996210文章來源地址http://www.zghlxwxcb.cn/news/detail-435463.html
到了這里,關于uniapp input框校驗數(shù)據(jù)格式,只能輸入漢字/數(shù)字/字母等的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!