我需要检查我的密码是否包含一个数字和一个字符。密码应至少包含一个数字和一个字符
输入形式
<input class="form-control" data-validate="required,minlength[8],alphaNumeric" id="password" name="password" placeholder="password" type="text">
下面是我jQuery的验证方法。
jQuery.validator.addMethod("alphaNumeric", function (value, element) {
return this.optional(element) || /^[0-9a-zA-Z]+$/.test(value);
}, "password must contain atleast one number and one character");
的问题是,上述正则表达式不验证对于其中password
应包含至少一个数字和一个字符的标准。
Uncaught语法错误:无效的正则表达式:/ ^(?= \ D * \ d)((?= [^ az] * [az])[0-9a-z] + $ /未终止的组 – Mathew 2014-09-01 10:54:25
对不起一个错字,它现在是固定的。 – anubhava 2014-09-01 11:02:40