Validate a Password's Format - March 2010
The application I'm currently working on accepts passwords. I wrote some code to validate the entered passwords format. I encapsulated the code in a class module called cPassword.vb. The following edits are performed:See 'Generate a Random Password - November 2009' for VB code that generates a password.
- Must not be blank.
- Must not contain spaces.
- Can't be to short.
- Can't be too long.
I wrote a VB.Net VS2008 web application to demonstrate the code. Some screen shots:
The Password is OK
The Password is 'blank'
The Password contains spaces.
The Password is too short.
The Password is too long.
Methods Returns Valid(sPassword) Returns True if passes the tests. Invalid(sPassword) Returns True if fails the tests. Properties Default Description iMinLength 6 The minimum length. iMaxLength 15 The maximum length. sErrorMessage Contains an error message if it fails.
Contains the OK message if it passes.
If .Valid(sPassword) Then
|Download - Source||Zipped File||Size|
|VS2008 VB Solution||PasswordValid.zip||28K|
Previous Tip Tip Index Next Tip