Restrict space in textbox using JavaScript.

Vishalneeraj-24503
Posted by Vishalneeraj-24503 under JavaScript category on | Points: 40 | Views : 499
Write below Javascript code:-
32 is for Space as ASCII CODE

<script type = "text/javascript">
function Disable_Space()
{
if(event.keyCode == 32)
{
event.returnValue = false;
return false;
}
}
</script>

<asp:TextBox ID = "txt_user_id" onkeypress = "return Disable_Space();"
runat = "server"></asp:TextBox>

Comments or Responses

Login to post response