Click here to Skip to main content
15,920,632 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All

I need to restrict text box to accept single quotation mark. Please anyone help me to achive this.

Thanks
Mohan
Posted

By using RegularExpressionValidator you can make it work

Set the ValidationExpression ='^[^\"]*$' to restrict quotes input.

Refer similar discussion on CP: Validation of a textbox to prevent quotation marks to be used[^]
 
Share this answer
 
C#
<html>
<head>
	<script type="text/javascript" language="javascript">
		function checkQuote() {
			if(event.keyCode == 39) {
				event.keyCode = 0;
				return false;
			}
		}
	</script>
</head>
<body>
	<input type="text" onkeypress="return checkQuote();" />
</body>
</html>
 
Share this answer
 
Comments
Thomas Daniels 24-Jun-13 9:31am    
Reason for my vote of 2: you validate the text box at client-side. But ALWAYS validate stuff at server-side. If someone disables JavaScript in his browser, then you don't longer validate the textbox.
try using regular expression's.
 
Share this answer
 
Use ajaxtoolkit:filteredtextboxextender & made FilterType="Numbers, UppercaseLetters, LowercaseLetters"
 
Share this answer
 
v2
Comments
VICK 24-Jun-13 8:34am    
Hey Mukesh.. you said that if we could put the "" in Valid Chars than that will be restricted??????

ON the other side I think that this tag is used to describe the valid characters which you wana allow in your fields.... is not so???


http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/FilteredTextBox/FilteredTextBox.aspx

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