?
Solved

Password Complexity with validation expressions

Posted on 2004-08-19
5
Medium Priority
?
406 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 9

Assisted Solution

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


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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

741 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