Click here to Skip to main content
15,943,477 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to validate the password (strong password having atleast 1 charecter 1 number and 1 special charecter) in vb.net
Posted

The easiest way is to use a regular expression to check if the entered password is valid. The expression ((?=.*\\d)(?=.*[A-Za-z])(?=.*[@#$%])) will check if the entered password contains at least 1 number(?=.*\\d), 1 letter(either upper or lower case(?=.*[A-Za-z]) and 1 character in the list (?=.*[@#$%]).
 
Share this answer
 
Comments
silverswim_1987 21-Mar-12 13:15pm    
i didnt understand
Hi,
Here is the code Which dont use RegEx (Regular Expression)-

VB
Dim i,j,k As Byte
Dim c as Char
   For Each c In Textbox1.Text
       If Not Char.IsLetterOrDigit(c.ToString(),0) Then
       'Will count special characters
       i += 1
       ElseIf Char.IsLetter(c.ToString(),0) Then
       'Will count characters
       j += 1
       ElseIf Char.IsDigit(c.ToString(),0) Then
       'Will count numbers
       k += 1
       End If
   Next
    
       If i >= 1 and j >= 1 and k >=1 Then
       MsgBox("Password is Strong")
       Else
       MsgBox("Password is Weak")
       End If
 
Share this answer
 
Comments
silverswim_1987 27-Mar-12 13:29pm    
thnx javya its work dude thnx
Jαved 29-Mar-12 5:08am    
Anytime for you dude.
Accept it as answer then.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900