我正在创建一个join now
页面。我正在使用登录名,密码,确认密码和电子邮件进行注册。这些输入我验证通过javascript,我检查login name
确实存在或不通过ajax.If它存在,我只是显示一个味精this id exists already please chose another one.
问题:是,如果用户键入登录ID已存在,ajax会显示已存在,但用户仍然可以点击提交,因为这段时间JavaScript会通过它,因为登录ID字段不为空.even我可以在服务器端db进程检查这个,但是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.
我的ajax代码 -如何在php中通过ajax设置标志或指标?
...
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("loginName").innerHTML=xmlhttp.responseText;
}
}
...
db文件 -
//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>";
}
或者我怎么可以设置登录ID文本框为空字符串与阿贾克斯的错误味精一起?一些喜欢 -
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>";
}