Home All Groups Group Topic Archive Search About

RegularExpressionValidator problem

Author
21 Jan 2009 12:30 AM
Eric L
Trying to use a regex validator control to check password complexity
requirements in an ASP.NET 1.1 web app.  Here is the regex:
(?=(.*?[a-z].*?){2,})(?=(.*?[A-Z].*?){2,})(?=(.*?\d.*?){2,})(?=(.*?[!#\$%\^&\*@_\|\-=`~\[\]\{\},<>].*?){2,})^.{14,32}$

The expression uses lookaheads to check for two lowercase, two uppercase,
two numeric, and two listed special character, and to verify that the length
of the entire string is between 14 and 32 characters.

Using the System.Text.RegularExpressions.Regex.IsMatch method reports
correctly based on the input string, but the ASP.NET validator control always
reports that any input does not match the regex.  Anyone have an idea why? 
Any workarounds to get client side validation to work using the validator
control?  Upgrading is out as this is a legacy .NET 1.1 I'm supporting.

Author
21 Jan 2009 1:58 PM
Paul Shapiro
Check the documentation, but I seem to remember the regex validator has to
use a JavaScript-compatible expression or else disable client-side
validation.

Show quoteHide quote
"Eric L" <Er***@discussions.microsoft.com> wrote in message
news:D6DEA7C0-F043-419A-8E21-BABF59D072A6@microsoft.com...
> Trying to use a regex validator control to check password complexity
> requirements in an ASP.NET 1.1 web app.  Here is the regex:
>
> (?=(.*?[a-z].*?){2,})(?=(.*?[A-Z].*?){2,})(?=(.*?\d.*?){2,})(?=(.*?[!#\$%\^&\*@_\|\-=`~\[\]\{\},<>].*?){2,})^.{14,32}$
>
> The expression uses lookaheads to check for two lowercase, two uppercase,
> two numeric, and two listed special character, and to verify that the
> length
> of the entire string is between 14 and 32 characters.
>
> Using the System.Text.RegularExpressions.Regex.IsMatch method reports
> correctly based on the input string, but the ASP.NET validator control
> always
> reports that any input does not match the regex.  Anyone have an idea why?
> Any workarounds to get client side validation to work using the validator
> control?  Upgrading is out as this is a legacy .NET 1.1 I'm supporting.