Pregunta

I am using jQuery-Validation-Engine and hoping to find a custom[passsword] logic that I can add to jquery.validationEngine-en.js that will check for multiple criteria all at once (Requirements: 9 MinChars, 1 UpperCase, 1 LowerCase, 1 Numeric, and 1 SpecialChar). I do not know javascript well enough to even attempt this. I have searched and have been surprised it is not already out there. And possibly it has to be numerous individual ones ? like minSize and maxSize used together in

input type="password" name="password1" id="password1" size="44" maxlength="44"
      class="validate[required,minSize[8],maxSize[10],custom[password]]" 

This is the EMAIL Check

"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"

What Would the PASSWORD one look like ?

"password": {

    "regex":            ,

    "alertText": "* Invalid password"

I would ideally like it to Alert for the specifc item that is not being input (ie:) No Upper Case Letter, No Numberic, No Spcecial Character, etc.
Thanks In Advance

¿Fue útil?

Solución

Well, baptism by fire, but got er done. I had to break these up, which is really what I wanted to do anyways, so that individual Alert Texts could be used for the different criteria required and not one general invalid password message. With the help of regexlib.com I was able to add numerous custom validations within jquery.validationEngine-en.js The minSize[n] and required are already built into the jQuery Validation, so not showing those.

            "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"
            },

Usage; <input type="password" class="validate[required,minSize[8],custom[minNumberChars],custom[minSpecialChars],custom[noFirstNumber],custom[minUpperAlphaChars],custom[minLowerAlphaChars]]" name="password1" id="password1" size="44">

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top