In my PHP file, I have a submit button for the form coded like this:
<input type="submit" name="submit" value="submit" disabled="true" />
Next, I initiate 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";
}
}
}
Essentially, it's checking the availability of a username and enabling the submit button if the entered username is available. However, the button doesn't seem to enable as expected. Can anyone shed light on why this might be happening?