View Full Version : ajax debugging

10-28-2010, 12:55 PM
i'm trying to use ajax to check if a username already exists when registering

I have

function zvalidateusername(username) {
var validusername = true;
// alert(mobilenumber);
http.open("GET", "checkusername.asp?username=" + username, true);
http.onreadystatechange = function() {
if (http.readyState == 4) {
myresult = http.responseText;
// alert(myresult);
if (myresult != "True") {
// alert(myresult);
// validusername = false;
alert("שם משתמש נמצא כבר בשימוש במערכת");
return false;
else {
return true;
// alert(document.forms['register'].ccvalid.value);


and then within my validation

if (!zvalidateusername(document.getElementById("x_Username").value)) return false;

but this makes you not able to ever submit the form?
why would this be>

the following works in validation

if (!checkValidString(document.getElementById("x_Username").value)) return false;
if (!checkValidString(document.getElementById("x_Password").value)) return false;

10-28-2010, 01:54 PM
I solved the issue

i had to put the return true or return false at the end