Disable Spaces and force text field to lowercase
How to Disable Spaces and force text field to lowercase with jquery!
by kang cahya
HTML
<input id="form-input" placeholder="Type some text here...">
CSS
input {
border: 3px solid #9E9E9E;
border-radius: 5px;
height: 45px;
width: 450px;
font-size: 24px;
color: #212121;
margin: 25px 0px 0px 25px;
padding: 15px;
}
JavaScript
$("#form-input").on({
keydown: function(e) {
if (e.which === 32)
return false;
},
keyup: function(){
this.value = this.value.toLowerCase();
},
change: function() {
this.value = this.value.replace(/\s/g, "");
}
});