Regex query

  • Thread starter Thread starter Shaun Wilde
  • Start date Start date
S

Shaun Wilde

When using the regular expression validator is there a way of failing a
validation when you detect a match - I suppose a sort of anti-match.

I want to detect certain things on user input and if they exist then fail
client-side validation.

An example would be detecting html input, a simple test of which would be to
look for '<[a-zA-z]',
but I would like to fail if this sequence is detected anywhere in a
multiline string.

Is there a way or is it down to server-side validation only?

Shaun

PS. I am still validating the input on the server-side I just wanted to cut
down on round trips
 
Hi Shaun,

Based on my understanding, you want to reverse the process logic of
RegularExpressionValidator control.

To get this done, I think you should use CustomValidator control, which
allows you to write your own code to take part in the validation framework.
Then you can provide your own validate logic on the Form.

For more information about how to use CustomValidator control, please refer
to:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html
/aspplusvalid.asp

At client side, you may use JScript's RegExp class to do the regular
expression operation. For more information, please refer to the client
Jscript souce code below:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconscriptfileforsample.asp

In the article, RegularExpressionValidatorEvaluateIsValid method contains
the original RegularExpressionValidator control's logic. FYI.

====================================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Jeffrey

yup I was thinking along those lines myself as an alternative action - so
what you suggest is that I do a custom validator and then invert the result.
Seems reasonable, I was just hoping there wassome unknown regex expression I
didn't know about.

I'll test it out later and get back to you

shaun

"Jeffrey Tan[MSFT]" said:
Hi Shaun,

Based on my understanding, you want to reverse the process logic of
RegularExpressionValidator control.

To get this done, I think you should use CustomValidator control, which
allows you to write your own code to take part in the validation framework.
Then you can provide your own validate logic on the Form.

For more information about how to use CustomValidator control, please refer
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html
/aspplusvalid.asp

At client side, you may use JScript's RegExp class to do the regular
expression operation. For more information, please refer to the client
Jscript souce code below:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconscriptfileforsample.asp

In the article, RegularExpressionValidatorEvaluateIsValid method contains
the original RegularExpressionValidator control's logic. FYI.

====================================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Shaun,

Thanks for your feedback.

Yes, the key point is how to do the do the validation through regular
expression at client.

I will wait for your feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Shaun,

Here's an alternative solution. My product "Professional Validation And
More" (at http://www.peterblum.com/vam/home.aspx) is a replacement to the
built in validators that overcomes their numerous limitations. For example,
all of my 22 validators have a property called NotCondition that when true,
reverses the logic. So you'd plug in my RegexValidator, set the expression
that you want to be false and set NotCondition to true.
This works fully on the client side and my validators support more browsers
for client-side validation than Microsofts. (They support DHTML only; I
support IE, IE/Mac, Netscape/Mozilla, Opera 7, and Safari.)

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 
Hi Shaun,

Have you tried it yet? Do you still have any concern?

Please feel free to let me know, I will help you. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top