vue.js 입력 상자 입력 값 자동 필터 특수 문자 대체 문장부호 작업
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 특수 문자 입력 금지 숫자 정규 검증만 입력 가능나는 쓸데없는 말을 더 이상 하지 않겠다. 모두들 코드를 직접 보는 것이 좋겠다.
<el-input
size="small"
v-model="city"
placeholder=" "
@blur="addCity(scope.$index)"
@keyup.native="btKeyUp"
@keydown.native="btKeyDown"
></el-input>
// 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 그렇지 않으면 이벤트를 정상적으로 실행할 수 없습니다.다음은 숫자만 입력할 수 있습니다.
<el-input
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"
></el-input>
//
UpNumber(e) {
e.target.value = e.target.value.replace(/[^\d]/g,"");
}
이상js 입력 상자 입력 값 자동 필터 특수 문자 교체 중 문장부호 조작은 편집자가 모두에게 공유한 모든 내용입니다. 참고 부탁드리고 저희를 많이 사랑해 주십시오.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
[백견불여일타/Vue.js] 4장 - 입력 폼 데이터 가져오기v-model 데이터 입력 select 지난 장에서는 v-bind를 이용해서 HTML 태그 속성 값을 Vue로 다루는 법을 배웠습니다. 이번에는 사용자가 입력한 데이터를 Vue로 가져오는 법에 대해 다룹니다. 웹 페...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.