Forum Moderators: open
I have a small script that looks up a new registrant's desired username, and then it let's the registrant know if it is available. The script works fine in IE but not FF. FF gives the error:
document.getElementById("username") has no properties
updateName()index.php
onblur(blur )
The script is called by the following input field:
<input class="textfield" type="text" size="30" name="username" value="" onblur="updateName();" />
Here is the script in the page <head>...any ideas what I should modify?
<script language="javascript" type="text/javascript">
//This is the location of the PHP script plus a variable
var url = "validate.php?param=";
function updateName() {
// Clear the error div if username is re-submitted.
document.getElementById('checked').innerHTML = "";
// Print the message to use while checking the database
document.getElementById('animate').innerHTML = "<img src=\"images/ajaxloading.gif\">";
var name = document.getElementById('username').value;
var xmlHttpReq = false;
var self = this;
// Mozilla/Safari
if (window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();
}//if
// IE
else if (window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}//else if
self.xmlHttpReq.open("GET", url + escape(name) + "&flag=join", true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
//handle results
self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200) {
results = self.xmlHttpReq.responseText;
// Turn off animated .gif
document.getElementById('animate').innerHTML = "";
// Print the result
document.getElementById('checked').innerHTML = results;
}//if
else {
// Do nothing, let the image spin until the server responds
}//else
}//function
self.xmlHttpReq.send(null);
}//updateName
</script>