Here, we will show how you can allow only characters and space to be typed in a textbox. This is some time requirement to only need characters and space in textbox.
First we create html for enter characters and space in textbox.
Allow only characters and space in textbox javascript
Allow only characters and space in textbox javascript
Above code we use onkeypress javascript event.
Below is javascript code for validate typed characters and space
.
function onlyCharSpace(evt) {
evt = (evt) ? evt : window.event;
var charCode = (evt.which) ? evt.which : evt.keyCode;
if ((charCode > 64 && charCode < 91) || (charCode > 96 && charCode < 123) || (charCode==32)) {
return true;
}
return false;
}
I hope this article helps you.
Thanks for visiting Inflay.com .