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);
$(‘input[type=”submit”]’).attr(‘disabled’ , true);

/*Add and remove readonly to a textbox*/

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

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 )

Connecting to %s