ValidationExpression Error

S

skardian

I am currently using the ChangePassword control for ASP.NET 2.0 to
allow users to update or change their password as need be. However I am
running into a problem with the Regular Expression Validation. I have
tried the following code:

ValidationExpression="[\w]{5,}"

ValidationExpression="[\w|\d]{5,}"

ValidationExpression="^[\w]{5,}$"

ValidationExpression="^[\w|\d]{5,}$"

ValidationExpression="\w{5,}"

But each time the validation check ends. I am entering a password that
is 9 characters long to test so I know it's not a length issue. So what
exactly am I missing as from my research on the subject one of those
above expressions should work for validating that the field is 5
characters or more.

-Steve
 
S

skardian

Rad,

Tried that one but it still errors out on me.

<asp:RegularExpressionValidator ID="valPasswordLength" runat="server"
ControlToValidate="NewPassword" SetFocusOnError="true"
Display="Dynamic" ValidationExpression="^\w{5,}$" ErrorMessage="New
Password must be at least 5 characters long." ToolTip="New Password
must be at least 5 characters long."
ValidationGroup="ChangePassword1">*
</asp:RegularExpressionValidator>

That is the Validator element of the asp:Changepassword control that I
am using. Maybe something else in there is wrong but I just don't see
what the problem is.
Hey Steve,

Try this one

^\w{5,}$
--


Bits. Bytes.
http://bytes.thinkersroom.com
------------------------------


I am currently using the ChangePassword control for ASP.NET 2.0 to
allow users to update or change their password as need be. However I am
running into a problem with the Regular Expression Validation. I have
tried the following code:

ValidationExpression="[\w]{5,}"

ValidationExpression="[\w|\d]{5,}"

ValidationExpression="^[\w]{5,}$"

ValidationExpression="^[\w|\d]{5,}$"

ValidationExpression="\w{5,}"

But each time the validation check ends. I am entering a password that
is 9 characters long to test so I know it's not a length issue. So what
exactly am I missing as from my research on the subject one of those
above expressions should work for validating that the field is 5
characters or more.

-Steve
 
R

Rad [Visual C# MVP]

Hey Steve,

If I understand you correctly you have a ChangePassword control on
your form, and you want to validate the new password such that it is
at least 5 characters.

I've recreated the scenario on my PC. What you want to do is put the
regular expression ,^\w{5,}$, in the property
NewPasswordRegularExpression.

If you view source at this point your control's source should be as
follows:

<asp:ChangePassword ID="ChangePassword1" runat="server"
NewPasswordRegularExpression='^\w{5,}$'>
</asp:ChangePassword>

Try that out and let me know if it works. I've been able to test it on
my PC and it works like poetry
 

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,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top