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

Tech-Archive recommends: Speed Up your PC by fixing your registry



On 5 Nov, 13:44, Jesse Houwing <jesse.houw...@xxxxxxxxxxxxxxxx> wrote:
Hello hamsterch...@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

that is exactly what im trying to do - avoid sql injections - waht
woudl you reccomend fine sir?

BTW thanks for helping

.



Relevant Pages

  • Re: I need validation to fail on an apostrophe entered into a textbox for my regularexpression valid
    ... you are not entering in any apostrophes." ... regular expression to return a no match on the above line. ... SQL injection or cross site scripting, then adding a regex validator to your ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Regular Expression Function
    ... I want a regular expression to compare sentences and then rate them as ... I have an array with a list of other phrases like so... ... characters will throw things off. ... "In an hour the system will go down for maintenance". ...
    (alt.php)
  • Re: Regular Expression Function
    ... I want a regular expression to compare sentences and then rate them as ... I have an array with a list of other phrases like so.. ... These will be stripped from the input first. ... characters will throw things off. ...
    (alt.php)
  • Re: Expert script (.bat) writers help needed (strip double-quote from string)
    ... Sets or returns the regular expression pattern being searched for. ... Always a RegExp object variable. ... May include any of the regular expression characters defined in the table in the Settings section. ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: RegExp and special caracters
    ... function identifier(str, substr) ... Expression syntax called POSIX 1003.2 Basic Regular Expressions (considered ... where special characters are to be escaped in order not to be considered ... Expressions modelled after the Regular Expression flavor Perl 5 supports ...
    (comp.lang.javascript)