2

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"/>

3 Answers 3

1

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');
Sign up to request clarification or add additional context in comments.

Comments

1

You can remove the attribute disabled:

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

Comments

0

I would suggest you to use removeProp jQuery method instead:

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

Or removeAttr

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

7 Comments

so u mean to say i have to remove to document.getElementById('signupb').disabled = false; and add $( '#signupb' ).removeProp( 'disabled' ); IS it?
@AbhishekMahapatra yes, or removeAttr method. You can choose.
can i chane in input filed ,what i wrote
@AbhishekMahapatra I don't understand what you mean.
In input tag i wrote <input disabled="true"> can i remove or not?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.