当前位置:网站首页>el-form特殊字符校验
el-form特殊字符校验
2022-07-17 00:06:00 【静止呀】
el-form文本框输入特殊字符校验,除中文句号,逗号,双引号,小括号,冒号,英文句号,逗号,双引号,小括号,冒号外,其余特殊字符全部禁止输入。
<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("不能含有特殊字符"))
} else {
callback()
}
}
return {
// 表单校验规则
formRules:{
content: [
{
required: true, message: "请输入不超过200字符", trigger: 'blur'}, // 这里三元运算失效了。
{
validator: vaildateInput, trigger: ['blur','change']} // 这里三元运算ok
]
}
}
},
methods: {
// 特殊字符校验
checkSpecicalKey(str){
// 以下特殊字符禁用
let specialKey = "[`[email protected]#$^&*_-+=\/=|{}';'\\[||]<>/?·~!@#¥%&……*————{}——|《》‘’【】''、?]"
for (let i = 0; i < str.length; i++) {
if (specialKey.indexOf(str.substr(i,1)) != -1) {
return false
}
}
return true
}
}
边栏推荐
- object-fit:cover; It doesn't work in the applet. How to deal with the deformation of the applet image
- Redis简单使用
- 时间戳转化时间
- uni 阻止按钮多次点击 按钮多次点击
- About foreign key references, cross domain headers, and ref usage
- 今天的码农女孩总结了关于npm包管理和url模块的笔记
- Eye of depth III - (7, 8)] mathematics: matrix diagonalization and quadratic form 2.3
- Colorful text advertising code, text advertising code beautification version, add text advertising tutorials to the website
- 量化行业知识汇总
- Understand PHP from [Fifth space 2021] easycleanup_ session
猜你喜欢
![Eye of depth III - (7, 8)] mathematics: matrix diagonalization and quadratic form 2.3](/img/fd/2808b277cdbf06ab7b041225d8d17e.png)
Eye of depth III - (7, 8)] mathematics: matrix diagonalization and quadratic form 2.3

Redis简单使用

MoveIt2——2.MoveIt在RViz中的快速入门

Common mode attack and shared prime of RSA

Summary of Applied Cryptography

JS intercepts the first few digits of the string or the last few digits of the string

使用bat自动执行cmd命令(多个命令或单个命令)

网站如何统计访问人数?51LA如何安装使用?

自己封装的风格化的开关卡片组件

mock平台的使用说明
随机推荐
Fundamentals of IOT development
Uni app wechat applet - Mall (6) - my home page
uni-app微信小程序——商城(7)——商品详情
Cve-2022-34265 Django extract & TRUNC SQL injection vulnerability recurrence
Raw Socket抓包,某些端口的数据包抓不到
分布式之数据库和缓存双写一致性方案解析(转载)
js字符串转对象 js对象转字符串 js字符串与对象互转
CTF CRYPTO RSA入门刷题
缤纷彩色文字广告代码,文字广告代码美化版,给网站添加文字广告教程
(八)Shell函数
Record buuctf [netding Cup 2018] unfinish1 problem solving ideas
wget 警告: 无法验证
ModelArts-人声检测and文本分类
Uni app wechat applet - Mall (7) - Product Details
three.js初体验:模拟一个小树杈的生长
object-fit:cover;在小程序中不起作用,小程序图片变形了如何处理
The C Programming Language (2nd)--笔记--1.7
E-commerce background management login
uniapp调用地图,进行位置查询,标记定位
If the website is hacked, what if you jump to other websites through Baidu / Sogou and other search keywords?