Trim Input Whitespace /* trim-whitespace-input.js*/ $('.no-spaces-field').keyup(function() { $(this).val($(this).val().replace(/ +?/g, '')); });