我就废话不多说了,大家还是直接看代码吧~


verifyInput(v){

let _this=this;

let punctuation = /[`~!@#$%^&*_\-=<>?:"{}|.\/;'\\[\]·~!@#¥%……&——\-={}|《》?:“”【】、;‘'。、]/im;

let arr=v.split('')

let str=''

arr.map(i=>{

if(!punctuation.test(i)){

str+=i

}

})

str=str.replace(/(/g,'(')

str=str.replace(/)/g,')')

str=str.replace(/,/g,',')

this.$nextTick(j=>{

this.relatedWords=str

})
},
verifyInput(v){

let _this=this;

let punctuation = /[`~!@#$%^&*_\-=<>?:"{}|.\/;'\\[\]·~!@#¥%……&——\-={}|《》?:“”【】、;‘'。、]/im;

let arr=v.split('')

let str=''

arr.map(i=>{

if(!punctuation.test(i)){

str+=i

}

})

str=str.replace(/(/g,'(')

str=str.replace(/)/g,')')

str=str.replace(/,/g,',')

this.$nextTick(j=>{

this.relatedWords=str

})
},补充知识:vue el-input 禁止输入特殊字符 只可输入数字 正则验证补充知识:补充知识:vue el-input 禁止输入特殊字符 只可输入数字 正则验证我就废话不多说了,大家还是直接看代码吧~
size="small"
v-model="city"
placeholder="请输入城市名称"
@blur="addCity(scope.$index)"
@keyup.native="btKeyUp"
@keydown.native="btKeyDown"
>

// methods内


// 只能输入汉字、英文、数字

btKeyDown(e) {

e.target.value = e.target.value.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5]/g,"");

},

//限制输入特殊字符

btKeyUp(e) {

e.target.value = e.target.value.replace(/[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘',。、]/g,"");

}
size="small"
v-model="city"
placeholder="请输入城市名称"
@blur="addCity(scope.$index)"
@keyup.native="btKeyUp"
@keydown.native="btKeyDown"
>

// methods内


// 只能输入汉字、英文、数字

btKeyDown(e) {

e.target.value = e.target.value.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5]/g,"");

},

//限制输入特殊字符

btKeyUp(e) {

e.target.value = e.target.value.replace(/[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘',。、]/g,"");

}在el-input 内 使用 keyup等事件 需要添加 .native 否则无法正常执行事件下面是 只可输入数字

size="small"

v-model="scope.row.order_number"

v-show="scope.row.isShowInp_order"

@blur="editOrder(scope.$index,scope.row)"

v-focus

@keyup.native="UpNumber"

@keydown.native="UpNumber"

class="table_input"

>


// 只可输入数字

UpNumber(e) {

e.target.value = e.target.value.replace(/[^\d]/g,"");

}

size="small"

v-model="scope.row.order_number"

v-show="scope.row.isShowInp_order"

@blur="editOrder(scope.$index,scope.row)"

v-focus

@keyup.native="UpNumber"

@keydown.native="UpNumber"

class="table_input"

>


// 只可输入数字

UpNumber(e) {

e.target.value = e.target.value.replace(/[^\d]/g,"");

}以上这篇vue.js 输入框输入值自动过滤特殊字符替换中问标点操作就是小编分享给大家的全部内容了,希望能给大家一个参考。