Click here to Skip to main content
15,887,940 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have one textbox.This textbox take all character except double and single
quote.how I can do this using regular expression validator(asp.net)
Posted
Updated 7-Mar-12 4:24am
v3
Comments
kashif Atiq 1-Feb-12 0:01am    
do you want validator on your asp.net page to validate that user does not enteres " and ' in any specific field?

If you wrote some simple regex before, you should be able to do this with a little effort. However, if you have limited background regarding the subject matter, I suggest you go through the links first.

Reference
http://www.regular-expressions.info/reference.html[^]

Regex with Javascript
http://www.regular-expressions.info/javascript.html[^]

Test your regex with this tool
http://www.regular-expressions.info/javascriptexample.html[^]
 
Share this answer
 
You can also use the FilteredTextBoxEntender from the AjaxControlToolkit.
Then set following properties of the FilteredTextBoxExtender
FilterMode = Custom<br />
FilterType = InvalidChars<br />
InvalidChars = '" 
(without commas else comma will also be considered invalid.)
 
Share this answer
 
v2
The following code can be used to disallow " and ' in TextBox
ASP
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
    ControlToValidate="TextBox1" ErrorMessage=" and ' are not permitted"
    ValidationExpression="[^"']*"></asp:RegularExpressionValidator>
 
Share this answer
 
Comments
[no name] 24-Dec-12 1:51am    
hi, I tried it but getting unexpected token.

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