0

I have a button that is styled with Bootstrap3, not sure if that really matters or not....

<button type="button" class="btn btn-danger" disabled="disabled" id="transmitDirectMail">Send</button>

And I have an jquery ajax that validates an input and enables/disables the button if the value is a valid Direct Mail.

$("#directMailAddress")
    .keyup(function () {
        transmitToDirectEmail = this.value;
        $.ajax({
            type: "POST",
            url: "./phiMail/ValidateDirectMail.php",
            cache: false,
            data: { dMail: transmitToDirectEmail }
        })
            .done(function( msg ) {
                if (msg = "0")
                    $("#transmitDirectMail").prop('disabled', true);;
                if (msg = "1")
                    $("#transmitDirectMail").prop('disabled', false);
            });
    });

The problem is that setting the prop enables the button. The ('disabled', true) does not disable the button.

0

1 Answer 1

5

That's because you are using = (assignment operator) instead of == or === for comparison.

.done(function( msg ) {
    $("#transmitDirectMail").prop('disabled', msg == "0");
});
Sign up to request clarification or add additional context in comments.

1 Comment

Sometimes it's the simple things. Just a typo in my code. Thank you.

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.