[newbie] RegularExpressionValidator problem

J

Jeff

Hey

asp.net 2.0

Here is some markup i have problem with:

<asp:TableRow>
<asp:TableCell CssClass="fieldname"
Width="120">Password:</asp:TableCell>
<asp:TableCell Width="160"><asp:TextBox ID="Password" runat="server"
TextMode="Password" Width="100%" /></asp:TableCell>
<asp:TableCell HorizontalAlign="Left">
<asp:RequiredFieldValidator ID="valRequiredPassword" runat="server"
ErrorMessage="Password is required" ValidationGroup="CreateUserWizard1"
ControlToValidate="password"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="valPasswordLength" runat="server"
ErrorMessage="Password too short" Display="Dynamic"
ValidationGroup="CreateUserWizard1" ControlToValidate="Password"
ValidationExpression="\w{7,}"></asp:RegularExpressionValidator>
</asp:TableCell>
</asp:TableRow>

The problem is that I always get the error message "Password too short" even
when I typed in at least 13 characters in password. I thought only 7
characters was needed..

What am I doing wrong here?

Jeff
 
K

Karl Seguin [MVP]

I'd expect that to work. Are you sure you're putting in valid characters to
work with the \w ?

System.Text.RegularExpressions.Regex.IsMatch("12345678901234", "\\w{7,}");
returns true, as we'd expect

Karl
 
D

David Longnecker

Jeff-

I just tried to recreate your problem in both Regulator and VS and can't
find the glitch.

--
Password: <asp:TextBox ID="Password" runat="server" />

<asp:RegularExpressionValidator
ID="valPasswordLength"
runat="server"
ErrorMessage="Password too short"
Display="Dynamic"
ControlToValidate="Password"
ValidationExpression="\w{7,}" />
--

When submitted, '123456' fails, but '1234567' and longer works like a champ
in both alpha and numeric. What type of data are you trying to verify?
Is it valid to match the \w (word)?

-dl
 

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,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top