当前位置:网站首页>El form special character verification
El form special character verification
2022-07-19 01:38:00 【Still】
el-form Text box input special character verification , Except Chinese full stop , comma , Double quotes , parentheses , The colon , English full stop , comma , Double quotes , parentheses , Outside colon , All other special characters are forbidden to be input .
<el-form
:rules="formrules"
:model="Form"
>
<el-form-item prop="content">
<el-input v-model="Form.content" type="textarea"></el-input>
</el-form-item>
</el-form>
data() {
let vaildateInput = (rule, value, callback) => {
if(!this.checkSpecicalKey(value)) {
callback(new Error(" Can't contain special characters "))
} else {
callback()
}
}
return {
// Form validation rules
formRules:{
content: [
{
required: true, message: " Please enter no more than 200 character ", trigger: 'blur'}, // Here the ternary operation fails .
{
validator: vaildateInput, trigger: ['blur','change']} // Here, ternary operation ok
]
}
}
},
methods: {
// Special character check
checkSpecicalKey(str){
// The following special characters are disabled
let specialKey = "[`[email protected]#$^&*_-+=\/=|{}';'\\[||]<>/?·~!@#¥%&……*————{}——|《》‘’【】''、?]"
for (let i = 0; i < str.length; i++) {
if (specialKey.indexOf(str.substr(i,1)) != -1) {
return false
}
}
return true
}
}
边栏推荐
- Determine whether the two timestamps are the same day
- Uni app wechat official account (4) - address management page
- 01_ Template syntax
- uni-app微信小程序——商城(7)——商品详情
- Colorful text advertising code, text advertising code beautification version, add text advertising tutorials to the website
- Vue project deployment, cleaning cache
- 判断两个时间戳是否是同一天
- Use bat to automatically execute CMD commands (multiple commands or a single command)
- js替换字符串某个字符,js修改字符串中指定字符
- Use redis - Zset to make Leaderboard
猜你喜欢
随机推荐
(6) Test command
jsx 编译
自己封裝的風格化的開關卡片組件
JSX compilation
Differences between let and const, let, const and VaR
[AHU2021校内赛] ez-injection
uni-app微信小程序——商城(7)——商品详情
Uni canvas intercepts pictures
小程序嵌入网页向小程序跳转并传参,微信小程序中实现公众号授权获取openId
Libtomcrypt密码库的使用
2022.7.7 summary of some errors
页面布局——三栏布局解决方式
PCRE bypasses regular
tp-watermark. JS web page add watermark plug-in
Quine injection of SQL injection
v-model原理及修饰符
记一次用canvas做出腾讯云首页banner流光效果的经历
单页面应用 SPA 和多页面应用 MPA
openGauss内核分析-统计信息与行数估计
今天的码农女孩做了关于生命周期的笔记以及动态时钟的练习









