Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to disable spaces and tabs for a input:text

var field = document.querySelector('[name="username"]');

field.addEventListener('keypress', function ( event ) {  
   var key = event.keyCode;
    if (key === 32) {
      event.preventDefault();
    }
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #disable #spaces #tabs
ADD COMMENT
Topic
Name
5+1 =