【发布时间】:2014-10-25 14:02:16
【问题描述】:
我需要检查我的密码是否包含一个数字和一个字符。
输入表格
<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 应该包含至少一个数字和一个字符的条件。
【问题讨论】:
标签: jquery regex jquery-validate