showing results for - "how to disable spaces and tabs for a input 3atext"
Claire
07 Jul 2018
1var field = document.querySelector('[name="username"]');
2
3field.addEventListener('keypress', function ( event ) {  
4   var key = event.keyCode;
5    if (key === 32) {
6      event.preventDefault();
7    }
8});