Click here to Skip to main content
13,507,984 members
Rate this:
Please Sign up or sign in to vote.
See more:
How to strenghten the password for a registration page and how to validate it in c#

I want some characters,numbers,Special characters,

<td style="text-align: left; width: 90px;">
                               <td style="font-family: Verdana; font-size: medium; font-style: normal; text-align: left">
                                   <asp:TextBox ID="txtpassword" runat="server" Width="208px" ></asp:TextBox>
                                   <asp:RegularExpressionValidator ID="regpass" runat="server"

                                       ErrorMessage="RegularExpressionValidator" ControlToValidate="txtpassword"

Posted 2-Sep-12 19:37pm
Updated 2-Sep-12 21:17pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Validating password with
-must be 8 characters including 1 uppercase letter, 1 special character & alphanumeric characters
(?=.*\d)        #   must contain at least one digit
(?=.*[A-Z])     #   must contain at least one uppercase character
(?=.*\W)        #   must contain at least one special symbol
   .            #   match anything with previous condition checking
{8,8}           #   length at least 8 characters and also maximum of 8

In one line:

* Password matching expression[^]
* Password Strength Validation with Regular Expressions[^]
* ASP.Net Regular Expression Validator to validate Minimum and Maximum Text Length[^]
Mohamed Mitwalli 3-Sep-12 2:21am
Prasad_Kulkarni 3-Sep-12 2:32am
Thank you Mohamed!
Shibiny 3-Sep-12 2:31am
I Used your code like this:

<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server"
ErrorMessage="RegularExpressionValidator" ControlToValidate="txtpassword"
It Worked fine,But data after error message,Entered data saved to database,how to prevent this
Prasad_Kulkarni 3-Sep-12 2:33am
Use retrun, if error occurs.
Shibiny 3-Sep-12 3:00am
How to do this
Shibiny 3-Sep-12 3:01am
add new event is not working after showing this error message
lukeer 3-Sep-12 3:12am
Show the relevant code snippet. Use the "Improve question" link for that (directly beneath your original question).
Shibiny 3-Sep-12 3:30am
How to use it in javascript
Manas Bhardwaj 3-Sep-12 6:07am
yup +5
Prasad_Kulkarni 3-Sep-12 6:13am
Thank you Manas!

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.180417.1 | Last Updated 3 Sep 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100