Introduction :
Hi, Here i will explain how to Avoid user to Enter Space in the Textbox using JavaScript, In previous Tutorials i have explained you How to Make Textbox Readonly and How to allow only numbers in JavaScript. Here to i use Keycode Values in keypress event to execute the function. Also blocked pasting the values into TextBox
Aspx and JavaScript code :
Hi, Here i will explain how to Avoid user to Enter Space in the Textbox using JavaScript, In previous Tutorials i have explained you How to Make Textbox Readonly and How to allow only numbers in JavaScript. Here to i use Keycode Values in keypress event to execute the function. Also blocked pasting the values into TextBox
Aspx and JavaScript code :
<html>
<head runat="server">
<title>FourthBottle.com</title>
<script type="text/javascript">
function
AvoidSpace() {
if
(event.keyCode == 32) {
event.returnValue = false;
return
false;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txt1" runat="server" onpaste="return false;" onkeypress="AvoidSpace()"></asp:TextBox>
</div>
</form>
</body>
</html>