Validation Control question

F

fiefie.niles

For a Password field I would like a Validation Control to make sure
the password contains alphanumeric and number and has 8 characters.
What Validation Control can I use for this purpose ?
Thank you.
 
M

Mark Fitzpatrick

You could do a regular expression. Regexlib has a great array of sample
regular expressions and you may be able to find an exact match for what
you're looking for, or get some ideas on how to make yours.

http://regexlib.com/default.aspx
 
F

fniles

Thank you for your help.
I tried the regular expression ^.{4,8}$ but even when I type in "asdf",
"1234", or "asdf1234" when I click on the submit button it keeps giving me
the error "Password must be between 4 and 8 characters in length". What did
I do wrong in the following Page1.aspx ? Thank you.
<body>
<form id="form1" runat="server">
<div>
<input id="txtPassword" runat=server type="password" />&nbsp;
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server" ControlToValidate="txtPassword"
ErrorMessage="Password must be between 4 and 8 characters in length"
ValidationExpression="^.{4,8}$"></asp:RegularExpressionValidator>
<br />
<asp:Button ID="txtSubmit" runat="server" Text="Submit" /></div>
</form>
</body>
 

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,780
Messages
2,569,611
Members
45,273
Latest member
DamonShoem

Latest Threads

Top