我正在使用jQuery-Validation-Engine并希望找到一个自定义的[passsword]逻辑,我可以添加到jquery.validationEngine-en.js,它将同时检查多个条件(要求:9 MinChars,1 UpperCase ,1个LowerCase,1个Numeric和1个SpecialChar)。我甚至不知道javascript甚至尝试这个。我已经搜索过并且感到惊讶它还没有在那里。可能它必须是众多的个体?像minSize和maxSize一起使用
input type="password" name="password1" id="password1" size="44" maxlength="44"
class="validate[required,minSize[8],maxSize[10],custom[password]]"
这是电子邮件检查
"email": {
"regex": /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
"alertText": "* Invalid email address"
PASSWORD会是什么样子?
"password": {
"regex": ,
"alertText": "* Invalid password"
我理想情况下会为没有输入的特定项目发出警报(即:)没有大写字母,没有数字,没有异性字符等。
在此先感谢
答案 0 :(得分:3)
minSize[n]
和required
已内置到jQuery验证中,因此不会显示这些验证。
"minLowerAlphaChars": {
// requires at least one lower case alpha character
"regex": /^(.*[a-z].*)/,
"alertText": "* Must include 1 lowercase character"
},
"minUpperAlphaChars": {
// requires at least one UPPER case alpha character
"regex": /^(.*[A-Z].*)/,
"alertText": "* Must include 1 uppercase character"
},
"minSpecialChars": {
// requires at least one SPECIAL character of the list in regex
"regex": /^(?=.*[!@#$%&*()_+}])/,
"alertText": "* Must include 1 special character"
},
"minNumberChars": {
// requires at least one NUMERIC
"regex": /^(?=.*\d)/,
"alertText": "* Must include 1 numberic"
},
"noFirstNumber": {
// requires first charecter NOT be NUMERIC
"regex": /^(?!\d)/,
"alertText": "* First Character can not be numberic"
},
用法;
<input type="password" class="validate[required,minSize[8],custom[minNumberChars],custom[minSpecialChars],custom[noFirstNumber],custom[minUpperAlphaChars],custom[minLowerAlphaChars]]" name="password1" id="password1" size="44">