I am creating a join now
page.I am taking login name,password, confirm password and email to be register. these inputs I am validating through javascript and I am checking that login name
does exist already or not through ajax.If it exists I am simply displaying a msg that this id exists already please chose another one.
Problem: is that if a user typed a login id that already exists, ajax will show that is exists already but still user can click on submit because this time JavaScript will pass it because login id field is not empty.even I can check this on server side db process but I want to set one indicator or flag kind of, until and unless user enters such login id that does not exist he wont be able to submit form.
my ajax code-
...
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("loginName").innerHTML=xmlhttp.responseText;
}
}
...
db file -
//check in user table
if($num_rows == 0)
{
echo "<font color='Green'>Ok, you can chose <b>$logid</b> as Login name.</font>";
}
elseif($num_rows >= 1)
{
echo "<font color='Red'><b>$logid</b> Ligin name has already been taken, Please chose another Login name.</font>";
}
Or how can I set login Id text box to empty string along with the error msg from ajax?something like-
elseif($num_rows >= 1)
{
?>
<script>
document.getElementById("newid").value="";
</script>
<?php
echo "<font color='Red'><b>$logid</b> Ligin name has already been taken, Please chose another Login name.</font>";
}