I have a submit button for my form in my PHP file like below.
<input type="submit" name="submit" value="submit" disabled="true" />
now i send an asynchronous request using a request object,
document.getElementById("username").onblur=function(){
username(this.value);
};
function username(value)
{
request = createRequest();
if(request==null) {
alert("Unable to create request");
return;
}
var url= "sign_up.php?value=" +
escape(value);
request.open("GET",url,true);
request.onreadystatechange = displayDetails;
request.send(null);
}
function displayDetails() {
if (request.readyState == 4) {
if (request.status == 200) {
checked = document.getElementById("check");
checked.innerHTML = request.responseText;
document.getElementById("submit").disabled="false";
}
}
}
here it basically is checking the availability of a username, now i enable the submit button,if a username enteres is available. But it really is not enabling the button. Can someone tell me why?
Get rid of the quotation marks, what you did was assigning a string “false” into the
disabledattribute of the HTML element. Change the last line to this: