判断是否是数字和字母的组合:
if (this.passWordA.match(/d/) && this.passWordA.match(/[a-zA-Z]/)) {
} else {
this.$toast('请输入6~16位字母与数字的组合')
return false
}
判断是否有非法字符:
let pattern = new RegExp("[`~!@#$^&*()=|{}':;',\[\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
let rs = ''
for (let i = 0; i < this.passWordA.length; i++) {
rs = rs + this.passWordA.substr(i, 1).replace(pattern, '')
}
if (rs !== this.passWordA) {
this.$toast('请勿输入非法字符!')
return false
}