Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i want to disable ' char for all inputbox,textbox in my asp.net web page by using Java Script or jQuery.
i need to write method like that will apply to all textbox and inputbox no need to apply individually.
Posted

$(document).ready(function()
{
$('#<%=textbox.ClientID%>').keypress(function(e)
{
var key=e.charCode;
if(key==96)
{
e.preventDefault();
}
});
});
 
Share this answer
 
Comments
aarif moh shaikh 20-Nov-14 0:25am    
good nice one...
Member 8825505 20-Nov-14 0:38am    
i Want to add function which will work for all text box in form no need to write single text box name.because i have more then 20 text box in 1 form and i have many forms please help.
Member 8825505 20-Nov-14 0:39am    
Compiler Error Message: CS0103: The name 'textbox' does not exist in the current context

Source Error:


Line 186: <script type="text/javascript">
Line 187: $(document).ready(function () {
Line 188: $('#<%=textbox.ClientID%>').keypress(function (e) {
Line 189: var key = e.charCode;
Line 190: if (key == 96) {

this code showing error like above.
Abid Shk 20-Nov-14 1:04am    
write your control ID in place of textbox
Member 8825505 20-Nov-14 1:07am    
i have so many controls i need to write java script automatically apply to all text box by its type.
All you need is well explained in this article, complete with self-containing code samples: http://www.javascripter.net/faq/keyboardinputfiltering.htm[^].

—SA
 
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