【发布时间】:2010-10-15 23:46:49
【问题描述】:
我已经使用 ajax/php 创建了一个表单验证。每个文本框都使用不同的文件进行验证,例如用户名_ajax.php。一旦信息被检查为正常,它就会在屏幕上回显(“用户名正常”)。一旦所有文本框都“确定”,我无法弄清楚如何允许用户只按下提交按钮。任何帮助将不胜感激,谢谢。
我的代码(抱歉太长了):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sign-up</title>
</head>
<script type="text/javascript">
function username(username)
{
var httpRequest;
make_request()
function stateck()
{
if(httpxml.readyState==4)
{
document.getElementById ("user_div").innerHTML=httpxml.responseText;
}
}
httpxml.onreadystatechange=stateck;
user_url="ajax_username.php?username=" + username.value;
httpxml.open("GET",user_url,true);
httpxml.send(null);
}
function email(email)
{
var httpRequest;
make_request()
function stateck()
{
if(httpxml.readyState==4)
{
document.getElementById("email_div").innerHTML=httpxml.responseText;
}
}
httpxml.onreadystatechange=stateck;
email_url="ajax_email.php?value=" + email.value;
httpxml.open("GET",email_url,true);
httpxml.send(null);
}
function confirm(password,conpassword)
{
var httpRequest;
make_request()
function stateck()
{
if(httpxml.readyState==4)
{
document.getElementById("conpass_div").innerHTML=httpxml.responseText;
}
}
httpxml.onreadystatechange=stateck;
conpassword_url="ajax_password.php?password=" + password.value + "&conpassword=" + conpassword.value;
httpxml.open("GET",conpassword_url,true);
httpxml.send(null);
}
</script>
<body>
<div id="user_div"></div>
<div id="conpass_div"></div>
<div id="email_div"></div>
<form id="form" name="form" method="post" action="">
<label>Username<br />
<input type="text" name="username" id="username" onBlur="check_username(username)">
<br />
<br />
</label>
<label>Password<br />
<input type="password" name="password" id="password" onBlur="check_confirm (password,conpassword);">
</label>
<label><br />
<br />
Confirm Password<br />
<input type="password" name="conpassword" id="conpassword" onBlur="check_confirm(password,conpassword);">
<br />
<br />
</label>
<label>Email<br />
<input type="text" name="email" id="email" onblur="check_email(email)" />
<p>
<p>
<label>
<input type="submit" name="button" id="button" value="Submit" onclick="return false;" />
</label>
</p>
</form>
</body>
</html>
【问题讨论】:
-
我无法弄清楚如何让用户只在所有文本框都“确定”后才按下提交按钮。是的....怎么样?