I have validated input fields to check for empty fields. Later I noticed someone can just enter white space and submit the form. Can someone help me remove white space before text but accept space in the middle of the text of the input. I tried using this but will not allow white space in the middle of the input
$('input').keyup(function() {
$(this).val($(this).val().replace(/\s+/g, ''));
});
How do I fix this?