x
Solved

# Password Complexity with validation expressions

Posted on 2004-08-19
Medium Priority
413 Views
This regular expression requires you to enter at least one letter, followed by any number of word characters, followed by at least one number, followed by any number of word characters.

[a-zA-Z]+\w*\d+\w*

Unfortunately, I cannot dictate to the user which placeholder is to be a number or a letter or a special character.  What I really need is the following:

If I have an 8 digit password field, it must meet the following validation:
Minimum of 1 Cap Letter, 1 Special Char, and 1 Numeric

This way I can put this password complexity on the Registration Page where the user creates their own password.

Any ideas?

THank you,
Jayme
0
Question by:jayme9
• 2
• 2

LVL 9

Assisted Solution

leechoonhwee earned 150 total points
ID: 11839122
Well you can add in some function like
Dim NumericCheck as boolean
Dim CapsCheck as boolean
Dim SpecialChar as boolean

for i = 1 to len(strPassword)

if Checknumeric (mid(strpassword,i,1) = false then
NumericCheck=true
end if

if .....check for caps
end if

if ....check for special chars....
end if

next

if NumericCheck = false then  'Doe not satisfy numeric criteria
.....error...
end if
if CapsCheck = false then ' Does not satisfy Caps check
.....error....
end if
if SpecialChars = false then ' Does not satisfy Special char checks
.....error
end if

Checknumeric = false
else
Checknumeric = true
end if

End function

thats the gist of it but i dunno how to check for Caps though.....
0

LVL 9

Accepted Solution

leechoonhwee earned 150 total points
ID: 11839168
ok got it..... Caps compare is

CheckCaps = false
else
CheckCaps = true

end function

0

Author Comment

ID: 11849606
I'll make it even simplier...

Here is the solution that allows the applicant to create their own password that meets the following complexity requirements: at least 8 characters long, with one lower case letter, one upper case letter, one digit, and one special character.

Password field ... On Validate --> Regular Expression Validation -->

^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#\$%^&*()+,?./;:"'<=>]).*\$

That's all there is to it.  It works fine.

Jayme
0

Expert Comment

ID: 12621268
What if I needed 2 Upper Case 2 Special Charectes 2 Numerals?
0

Author Comment

ID: 12622526
I haven't tried this, but it would be along the lines of this:

^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[1-9]{2,})(?=.*[A-Z]{2,})(?=.*[!@#\$%^&*()+,?./;:"'<=>]{2}).*\$

It basically says validate a string that is at least 8 characters with:
at least 1 lower case letter (a-z)
at least 2 numbers (1-9)
at least 2 upper case letters (A-Z)
at least 2 special characters within the set (!@#\$%^&*()+,?./;:"'<=>)

All that code would go behind your control's OnValidate event that is executed when a user clicks the submit button.  Again, I have not tried it, but it would probably be close to what I have above.

Jayme
0

## Featured Post

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.