Re: I need validation to fail on an apostrophe entered into a textbox for my regularexpression validator
- From: Jesse Houwing <jesse.houwing@xxxxxxxxxxxxxxxx>
- Date: Mon, 5 Nov 2007 13:44:35 +0000 (UTC)
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
.
- Follow-Ups:
- Re: I need validation to fail on an apostrophe entered into a textbox for my regularexpression validator
- From: hamsterchaos@xxxxxxxxx
- Re: I need validation to fail on an apostrophe entered into a textbox for my regularexpression validator
- References:
- I need validation to fail on an apostrophe entered into a textbox for my regularexpression validator
- From: hamsterchaos@xxxxxxxxx
- I need validation to fail on an apostrophe entered into a textbox for my regularexpression validator
- Prev by Date: Re: excel to xml
- Next by Date: Re: Does Page.RegisterClientScriptBlock Not Work Under ASP.NET 2.0
- Previous by thread: I need validation to fail on an apostrophe entered into a textbox for my regularexpression validator
- Next by thread: Re: I need validation to fail on an apostrophe entered into a textbox for my regularexpression validator
- Index(es):
Relevant Pages
|