Click here to Skip to main content
15,922,584 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In the following code, the regular expression validator is not validating when there is
a single qoute (') in the data "officer's quarters" available in DDL. It seems there is some
mistake in the validation expression for 'single quotes'.


XML
<asp:RegularExpressionValidator ID="RegularExpressionValidator77" runat="server"
ControlToValidate="DropDownList60" ErrorMessage="Item 5:select an area "
style="z-index: 1; left: 180px; top: 23px; position: absolute; height: 13px;"
ValidationExpression="[0-9 a-z ' -/.  ]{1,50}" Font-Size="X-Small"></asp:RegularExpressionValidator>


How to rectify it?
Posted
Comments
Thanks7872 25-Aug-13 6:02am    
Do you know the power of single quote while working with database?
S.Rajendran from Coimbatore 25-Aug-13 6:05am    
So, should I delete all existing single quotes in tables? If it is safe I will have to.
Thanks7872 25-Aug-13 7:04am    
Have a look at some SQL Injection info. You will get idea what i am trying to say. Its good practice to avoid inserting single quotes in DB.

1 solution

Hi,

You can add other special characters after '?' for validating special characters
as below --

[0-9a-zA-Z;/?'*@]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900