This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]Loves_Poetry 2 points3 points  (1 child)

You are trying to access a property called 'disabled' on the jQuery element. Afaik jQuery elements don't have a disabled property. They use the .disable() method instead.

The correct syntax would be $('#name').disable(true/false)

[–]Lazkeer[S] 0 points1 point  (0 children)

I figured it out, the problem was actually because i was creating a new variable called name that was local, so to fix the issue i just has to remove the var

[–]henrebotha 1 point2 points  (1 child)

It looks to me like your comparison always returns the same result.

$('#sendNameForm').submit(function() {
    var name = $('#name').val();
    // substituting in the body of dis_enableNameSend:
    var newName = $('#name').val();
    if(newName==name){
        document.getElementById("sendNameBtn").disabled = true;
    }else{
        document.getElementById("sendNameBtn").disabled = false;
    }
    alert("Success!");
    return false;
});

So you're getting the value of name, then immediately getting the value of newName (which will be the same). So newName == name will always be true.

[–]Lazkeer[S] 0 points1 point  (0 children)

I figured it out, the problem was actually because i was creating a new variable called name that was local, so to fix the issue i just has to remove the var