我正在創建一個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>";
}