Alright, so my form works like a dream in firefox. No problems what-so-ever. IE on the other hand... it's still a bit buggy. It's possible to submit the form, yes, but if you fill the form out correctly and receive no errors the first time, you have to click submit twice. After making one or two mistakes filling the form out, the submit button works on the first try. If you have more than two errors (duplicate username check returns true, or input fields not filled out correctly), then the form won't submit at all. THEN when you try to refresh, it acts like the page isn't available anymore...
I THINK it has something to do with sending multiple, rapid AJAX requests. I think it might be choking the browser. Anyone run into a similar problem? It's a lot of code to post, but here it is. Here's the link too:
https://www.avclan.net/wip/register.php
HTML Code:
<script type="text/javascript">
function numOnly(e, input, maxChars) {
var keynum;
var keychar;
var numcheck;
if (window.event) {
keynum = e.keyCode;
} else if (e.which) {
keynum = e.which;
}
// Allow Backspace, Delete and Arrowkeys
if (keynum == 8 || keynum == 127 || !keynum) {
return true;
}
numcheck = /\d/;
keychar = String.fromCharCode(keynum);
if (input.value.length >= maxChars) return false;
return numcheck.test(keychar);
}
function getIndex(what) {
for (var i=0;i<document.register.elements.length;i++) {
if (what == document.register.elements[i])
return i;
}
return -1;
}
function jumpIndex(e, input, maxChars) {
var i;
var num = input.value.length;
var keynum;
var keychar;
var chrcheck;
if (window.event) {
keynum = e.keyCode;
} else if (e.which) {
keynum = e.which;
}
if (num == maxChars && keynum != 8 && keynum != 127 && keynum != 9 && keynum) {
i = getIndex(input);
document.register.elements[i+1].focus();
}
}
function validate() {
var uname = document.register.uname.value;
var email = document.register.email.value;
var dname = document.register.dname.value;
var pass = document.register.pass.value;
var pass2 = document.register.pass2.value;
var birth_month = document.register.birth_month.value;
var birth_day = document.register.birth_day.value;
var birth_year = document.register.birth_year.value;
var imgtext = document.register.imgtext.value;
var testEmail = /^[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}$/;
if (!uname) {
alert("Please enter Username");
return false;
}
if (!email) {
alert("Please enter E-mail");
return false;
} else if (email && !testEmail.test(email)) {
alert("Incorrect e-mail address format");
return false;
}
if (!dname) {
alert("Please enter Display Name");
return false;
}
if (!pass) {
alert("Please enter Password");
document.register.pass.value = "";
document.register.pass2.value = "";
return false;
} else if (pass != pass2) {
alert("Password Mismatch");
document.register.pass.value = "";
document.register.pass2.value = "";
return false;
}
if (birth_month || birth_day || birth_year) {
var bday_flag = 0
if (!birth_month || birth_month.length < 2) bday_flag = 1;
if (!birth_day || birth_day.length < 2) bday_flag = 1;
if (!birth_year || birth_year.length < 4) bday_flag = 1;
if (bday_flag) {
alert("Birth date format incorrect");
return false;
}
}
if (!imgtext) {
alert("Type the letters shown in the image in the supplied textbox");
return false;
}
return true;
}
function processResponse(response) {
data = eval(response);
if (data[0] == 1 && data[1] == 0) {
document.register.submit();
} else if (data[1] == 1) {
alert("That username is taken");
} else if (data[0] == 0) {
alert("Invalid Serial");
}
}
function handleStateChange() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
processResponse(xmlHttp.responseText);
}
}
}
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
function startRequest(method, URL, serial) {
createXMLHttpRequest();
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open(method, URL, true);
xmlHttp.setRequestHeader(
'Content-Type',
'application/x-www-form-urlencoded; charset=UTF-8');
xmlHttp.send(serial);
}
function checkSerial(x) {
frm = x;
if (validate()) {
var serial = document.register.imgtext.value;
var user_name = document.register.uname.value;
var query = serial + "<!>" + user_name;
startRequest('POST', 'https://www.avclan.net/wip/checkserial.php', query);
}
}
</script>
<form id="register" name="register" method="post" action="createuser.php" onsubmit="checkSerial(); return false;">
...
<input type="submit" name="submit_form" value="Register" />
</form>