Re: I need validation to fail on an apostrophe entered into a textbox for my regularexpression validator



Hello hamsterchaos@xxxxxxxxx,

<asp:RegularExpressionValidator id="valRegEx" runat="server"
ControlToValidate="textbox1"
ValidationExpression=" "
ErrorMessage="* Please only enter alphanumeric values and make sure
you are not entering in any apostrophes."
display="dynamic">*
I need

"Chris's mail"

to fail the above validation - which I believe means I need the
regular expression to return a no match on the above line.

Can you help?

The expression must capture what it should be, not what it shouldn't be. In your case that's quite easy:

^[a-zA-Z0-9 ]+$

any alphanumeric character or space. You can add other allowed characters in there if needed.

I do wonder why you want to exclude these characters. If it is to prevent SQL injection or cross site scripting, then adding a regex validator to your textboxes isn't the best idea to employ.

--
Jesse Houwing
jesse.houwing at sogeti.nl


.



Relevant Pages

  • Re: RegularExpressionValidator
    ... the regular expression you specified is asking for a literal backslash followed by one or more w characters. ... you don't need to escape anything when specifying the expression in aspx. ... also a space to the text box being validated would pass the validation. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: regular expression to capture invalid emails
    ... I want to create a regular expression ... > matches any email address that ends in two characters like ... the address first (no comments on all the ways your check above would fail), ... Matt ...
    (comp.lang.perl.misc)
  • Re: Exchange 2007 Get-Recipient errors
    ... Narvekar has been corrupted and it is in an inconsistent state. ... following validation ... by at least one of the other characters. ... U+00FF are also valid in an alias, but they will be mapped to a best-fit ...
    (microsoft.public.exchange.admin)
  • Re: Exchange 2007 Get-Recipient errors
    ... Narvekar has been corrupted and it is in an inconsistent state. ... following validation ... by at least one of the other characters. ... U+00FF are also valid in an alias, but they will be mapped to a best-fit ...
    (microsoft.public.exchange.admin)
  • Re: Address basics
    ... lane way to 40A but in Sydney I have found the tank for 42 on the side of ... post office addresses, they might be "sub-addresses" within a single ... Is there any crime in applying the exact same validation for both ... Should we purge it of special characters, such as hypens, commas, ...
    (comp.databases.pick)