Abhishek Mahapatra
Abhishek Mahapatra

Reputation: 45

not able to enable button using javascript

i have 2 fields username and password and login button .Here if i click on username field,its showing number no of users .then if i click on user and password that login button has to enable.but it is not enabling.its enable,if i write both username and password ,then login button is enabiling,Can u please suggest Me?

$("#Username").keyup(function() {
    var len = $('#Username').val().length;
    if (len > 30 || len == 0) {
        $('#Username').css('background', 'rgb(255, 214, 190)');
        blsp();
        if (len != 0) {
            $('#nameal').css('color', 'rgb(255, 57, 19)').text('ID: Too long').fadeIn()
        } else {

        }
        flg.Username = 1
    } else {
        $('#Username').css('background', 'rgb(255, 255, 255)');
        flg.Username = 0;
        tcheck()
    }
});

function tcheck() {
    if (flg.Username == 0 && flg.Password == 0) {
        $('#signupb').css('opacity', '1').css('cursor', 'pointer');
        document.getElementById('signupb').disabled = false;
        // document.getElementById('signupb').enabled = false;
    } else {
        blsp();
    }
}


<input disabled="true" id="signupb" style="opacity: 0.2; cursor: default;" class="signin_btn" name=""   type="submit" value="Login"/>

Upvotes: 2

Views: 78

Answers (3)

Radonirina Maminiaina
Radonirina Maminiaina

Reputation: 7004

You can remove the attribute disabled:

$('#signupb').removeAttr("disabled");

Upvotes: 1

Tushar
Tushar

Reputation: 87203

You can use prop:

$('#signupb').prop('disabled', false);

Set one or more properties for the set of matched elements.

Docs: https://api.jquery.com/prop

OR

You can also use removeAttr:

$('#signupb').removeAttr('disabled');

Upvotes: 1

antyrat
antyrat

Reputation: 27765

I would suggest you to use removeProp jQuery method instead:

$( '#signupb' ).removeProp( 'disabled' );

Or removeAttr

$( '#signupb' ).removeAttr( 'disabled' );

Upvotes: 0

Related Questions