我有以下规则,并使用validate.js,但 regex似乎不起作用。下面是我的代码。
给出的条件:检查字符串是否至少有一个大写字母,至少一个符号和至少一个数字
password: {
presence: {
message: '^Please enter a password'
},
length: {
minimum: 5,
message: '^Your password must be at least 6 characters'
},
format: {
pattern: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[\w~@#$%^&+=`|{}:;!.?\""()\[\]-]{1,}$/,
message:
'^Must contain a capital, lowercase, number and a special character!'
}
}