Solved

Password Complexity with validation expressions

Posted on 2004-08-19
5
400 Views
Last Modified: 2008-02-01
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
Comment
Question by:jayme9
  • 2
  • 2
5 Comments
 
LVL 9

Assisted Solution

by:leechoonhwee
leechoonhwee earned 50 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


Function CheckNumeric (strPassword)

if not isnumeric(StrPassword) then
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

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

Function CheckCaps (StrPassword)

if StrComp( strpassword, uCase(Strpassword), vbTextCompare ) = false then
CheckCaps = false
else
CheckCaps = true

end function

0
 

Author Comment

by:jayme9
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])(?=.*[!@#$%^&*()+,?./;:"'<=>]).*$

Error msg states "Please enter a valid password."

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

Jayme
0
 

Expert Comment

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

Author Comment

by:jayme9
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now