How to disable spacebar in text box control using jquery


In this article I'm going to explain How to disable space bar in text box control using jquery. Just drag and drop one text box control to your asp.net web page. When user try to press space bar control its not allowing.

In this article I'm going to explain How to disable space bar in text box control using jquery.

Just drag and drop one text box control to your asp.net web page. When user try to press space bar control its not allowing.

Example:



<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript" src="jquery-1.2.6.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#TextBox1").keydown(function(event) {
if (event.keyCode == 32) {
event.preventDefault();
}
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>


Comments

Author: Rajasekar.K27 Mar 2013 Member Level: Silver   Points : 0

nice..



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: