RegularExpression Validation for password in ASP.NET

B

bienwell

Hi all,

Can any one help me to write a regular expression to validate the password
entered on the text field in ASP.NET. The rules for the password are:
1- There must be at least one number in the password.
2- There must be upper and lower case letters in the password.
3- Password must begin with an alphabetic character.
4- Password cannot contain illegal characters, such as =, <, >, ;, :, '
, " or comma (equal sign, greater sign, less than sign, semicolon, colon,
single quote, double quotes, comma).
5- Password must be between 8 and 25 characters.

I'm not good at writing the expression. Please help me out.

Thanks in advance.
 
R

RhythmAddict

Hi all,

Can any one help me to write a regular expression to validate the password
entered on the text field in ASP.NET. The rules for the password are:
1- There must be at least one number in the password.
2- There must be upper and lower case letters in the password.
3- Password must begin with an alphabetic character.
4- Password cannot contain illegal characters, such as =, <, >, ;, :, '
, " or comma (equal sign, greater sign, less than sign, semicolon, colon,
single quote, double quotes, comma).
5- Password must be between 8 and 25 characters.

I'm not good at writing the expression. Please help me out.

Thanks in advance.

RegularExpressions.Regex.IsMatch(lblYourPw, "(?!^[0-9]*$)(?!^[a-zA-Z]*
$)^([a-zA-Z0-9]{8,10})$"))

"Validates a strong password. It must be between 8 and 10 characters,
contain at least one digit and one alphabetic character, and must not
contain special characters" I think you're 90% of the way there (got
it from http://msdn2.microsoft.com/en-us/library/ms998267.aspx)
 
W

wisccal

I'm not a regex expert either, but based on the previous post, this
seems to work:

Regex.IsMatch(
input, "(?!^[0-9]*$)(?!^[a-z]*$)(?!^[A-Z]*$)(?!^[a-z0-9]*$)(?!^[A-
Z0-9]*$)^([a-zA-Z][a-zA-Z0-9]{8,25})$")
)

============
Regards,
Steve
www.stkomp.com
 
B

bienwell

Thanks fyi.

RhythmAddict said:
Hi all,

Can any one help me to write a regular expression to validate the
password
entered on the text field in ASP.NET. The rules for the password are:
1- There must be at least one number in the password.
2- There must be upper and lower case letters in the password.
3- Password must begin with an alphabetic character.
4- Password cannot contain illegal characters, such as =, <, >, ;, :,
'
, " or comma (equal sign, greater sign, less than sign, semicolon, colon,
single quote, double quotes, comma).
5- Password must be between 8 and 25 characters.

I'm not good at writing the expression. Please help me out.

Thanks in advance.

RegularExpressions.Regex.IsMatch(lblYourPw, "(?!^[0-9]*$)(?!^[a-zA-Z]*
$)^([a-zA-Z0-9]{8,10})$"))

"Validates a strong password. It must be between 8 and 10 characters,
contain at least one digit and one alphabetic character, and must not
contain special characters" I think you're 90% of the way there (got
it from http://msdn2.microsoft.com/en-us/library/ms998267.aspx)
 
B

bienwell

Thanks for your help.

I'm not a regex expert either, but based on the previous post, this
seems to work:

Regex.IsMatch(
input, "(?!^[0-9]*$)(?!^[a-z]*$)(?!^[A-Z]*$)(?!^[a-z0-9]*$)(?!^[A-
Z0-9]*$)^([a-zA-Z][a-zA-Z0-9]{8,25})$")
)

============
Regards,
Steve
www.stkomp.com
Hi all,

Can any one help me to write a regular expression to validate the
password
entered on the text field in ASP.NET. The rules for the password are:
1- There must be at least one number in the password.
2- There must be upper and lower case letters in the password.
3- Password must begin with an alphabetic character.
4- Password cannot contain illegal characters, such as =, <, >, ;, :,
'
, " or comma (equal sign, greater sign, less than sign, semicolon, colon,
single quote, double quotes, comma).
5- Password must be between 8 and 25 characters.

I'm not good at writing the expression. Please help me out.

Thanks in advance.
 
Joined
Dec 26, 2008
Messages
3
Reaction score
0
password validation

should not less than 6 char
should contains atleast one digit
should contains atleast one char.
here is java script:

var reg='(?=\\w*\\d)';
var reg1='(?!^[0-9]*$)(?!^[a-zA-Z]* $)^([a-zA-Z0-9]{6,10})$';

if(txt_NewPassword.value.length < 6)
{
lbl_Error.innerText="Password length Should not less than 6 character";
txt_NewPassword.focus();
}
else if(!txt_NewPassword.value.match(reg))
{
//alert(reg);
lbl_Error.innerText="Password Should contains atleast one Digit";
txt_NewPassword.focus();
}
else if(!txt_NewPassword.value.match(reg1))
{
alert(reg1);
lbl_Error.innerText="Password Should contains atleast one alphabet";
txt_NewPassword.focus();
}

regards,
ANKIT CHAMPANERIYA
MUMBAI
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top