vue项目中常用的正则校验表达式
1、大于0的正整数/^[1-9]\d*$/2、是否是数字和一个英文,分开const idContent = this.form.activityId.replace(/[^\d,+]/g, '')this.form.activityId = idContent.replace(new RegExp(',+', 'gm'), ',')3、只能是一个英文,分开const idContent = thi
·
一、各种规则正则表达式
1、大于0的正整数
/^[1-9]\d*$/
2、是否是数字和一个英文,分开
const idContent = this.form.activityId.replace(/[^\d,+]/g, '')
this.form.activityId = idContent.replace(new RegExp(',+', 'gm'), ',')
3、只能是一个英文,分开
const idContent = this.adddata.names.replace(' ', '')
this.adddata.names = idContent.replace(new RegExp(',+', 'gm'), ',')
4、第一位数不能输入0
this.firstdata.allowAmount = this.firstdata.allowAmount.replace(/^0/g, '')
5、只能输入汉字和英文和数字,不能输入空格以及特殊符号
var name=this.name.replace(/[`~!#$%^&*()_/\-+=<>?:"{'}|~!#¥@%·—……&*()={}|《》?:“”【】、;‘’,。、\s+]/g, '');
6、只能输入英文,不能输入空格以及特殊符号和汉字
var name=this.name.replace(/\s/g,"").replace(/[^a-zA-Z0-9]/g,"")
7、只能输入数字
this.account=this.account.replace(/[^\d]/g,'')
二、各种格式正则表达式
1、身份证号正则
/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[0-2])(([0-2][1-9])|10|20|30|31)\d{3}(\d|X|x)$/
2、手机号正则
/^((0\d{2,3}-\d{7,8})|(1[34578]\d{9}))$/
3、邮箱正则
/^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.]){1,2}[A-Za-z\d]{2,5}$/g
还有其他的正则随时更新…
更多推荐
已为社区贡献9条内容
所有评论(0)