Answers for "how to disable spaces and tabs for a input:text"

0

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();
    }
});
Posted by: Guest on May-28-2021

Code answers related to "how to disable spaces and tabs for a input:text"

Code answers related to "Javascript"

Browse Popular Code Answers by Language