Disable/enable submit button & readonly to textbox using jQuery


Using attr()” function we will enable or disable submit button please find below code.

$(document).ready(function() {
$(‘input[type=”submit”]’).attr(‘disabled’, true);
$(‘input[type=”text”]’).on(‘keyup’,function() {
if($(this).val() != ”) {
$(‘input[type=”submit”]’).attr(‘disabled’ , false);
}else{
$(‘input[type=”submit”]’).attr(‘disabled’ , true);
}
});
});

/*Add and remove readonly to a textbox*/

if(rBtnVal == "yes"){
         $("#no_of_staff").attr("readonly", false); 
     }
     else{ 
         $("#no_of_staff").attr("readonly", true); 
     }
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com 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