element input校验方法
<el-input
v-model="input"
@focus="onFcus"
@input="handleClick"
placeholder="请输入活动名称"
id="errorInput"
maxlength="20"
></el-input>
handleClick(value) {
this.input = value.replace(/\s*/g, "");
let nameRegx = /^[a-zA-Z0-9\u4e00-\u9fa5]+$/;
if (!nameRegx.test(value) && value != "") {
this.errorSpan = true;
this.canSearch = false;
document.getElementById("errorInput").style.border =
"1px solid #F56C6C";
} else {
this.canSearch = true;
this.errorSpan = false;
document.getElementById("errorInput").style.border =
"1px solid #DCDFE6";
}
},
网友评论