<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> <script type="text/javascript"> message = ("Sorry, you are not allowed to enter any spaces"); function nospaces(which) { x = which.value if (navigator.appName == "Netscape" ) { if (e.which == 32) { alert (message); return false } } if (navigator.appName == "Microsoft Internet Explorer") { if (event.keyCode == 32) { alert (message); return false; } } x = x.replace(/\s/g,""); // remove the unwanted space document.myform.textbox.value = x; } </script> </head> <body> <form name = "myform" action="#" method="post" > <input type="text" name ="textbox" id="textbox" onkeydown="nospaces(this)"> </form> </body> </html>
Tuesday, January 7, 2014
Remove the space in textbox using JavaScript
This code remove the space in form textbox value on onkeydown Event using .net form and JavaScript.
Labels:
.net,
javascript
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment