I found this code snippet in my index.html file:
<form>
<input onkeyup="firstnamecheck(this.value)" type="text" name="firstname" id="Start" class="Inputs" />
<button type="submit" name="Murad" id="tester" title="Register">Register</button>
</form>
And here's what I have in reg.js:
function firstnamecheck(str) {
if (str.length == 0) {
document.getElementById("firster").innerHTML = "";
return false;
} else if (3 > str.length > 0) {
document.getElementById("firster").innerHTML = "Firstname should be more than 3 characters";
return false;
} else if (str.length > 30) {
document.getElementById("firster").innerHTML = "Firstname should be less than 30 characters";
return false;
} else {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("firster").innerHTML = xmlhttp.responseText;
}
};
xmlhttp.open("POST", "era.php?f=" + str, true);
xmlhttp.send();
}
}
Despite the errors, the form can still be submitted even when a "return false" is triggered.