Skip to content

Instantly share code, notes, and snippets.

@andreascarpello
Created September 24, 2013 10:40
Show Gist options
  • Save andreascarpello/6683037 to your computer and use it in GitHub Desktop.
Save andreascarpello/6683037 to your computer and use it in GitHub Desktop.
Check input change and prevent submit with whitespace
$('#textinput').bind('input', function(e){
if( $(this).val().length > 0 && !/^\s+$/.test($(this).val()) ){
$('#submit').removeClass( 'disabled' );
} else {
$('#submit').addClass( 'disabled' );
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment