Greying out submit button untill user give input : jQuery snippets #1

The submit button needs to wait till the user enter something into the input box. This is useful in most cases, where null injection can cause trouble

* The button should initially become disabled
* It should become alright after the user enters some stuff
* It should go back to disabled state once the user have cleared everything out


$( ‘#buttonClick’ ).prop( ‘disabled’, true );
$(‘.input’).on(‘input’, function() {
$(this).next().prop(‘disabled’, $(this).val().length < 1);

Hope it helps someone.

Related links:-

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s