——————————reg.asp——————————————————
<HTML>
<HEAD>
<TITLE>用户注册页面</TITLE>
<SCRIPT language="JavaScript">
function Check()
{
if ( reg.username.value==""){
alert ("提示:\n\n请填写需要查询的用户名!");
reg.username.focus();
return false;
}
if (!CheckIfEnglish(reg.username.value ) || reg.username.value.length > 12 || reg.username.value.length < 3) {
alert("提示:\n\n您的用户名不符合规范,必须3-12个英文字母或数字!");
reg.username.focus();
return false;
}
var uName=document.reg.username.value;
window.open("regcheck.asp?username="+uName,"check","width=320,height=100,left=200,top=200");
}
function CheckIfEnglish( String )
{
var Letters = "abcdefghijklmnopqrstuvwxyz0123456789-";
var i;
var c;
if(String.charAt( 0 )=='-')
return false;
if( String.charAt( String.length - 1 ) == '-' )
return false;
for( i = 0; i < String.length; i ++ )
{
c = String.charAt( i );
if (Letters.indexOf( c ) < 0)
return false;
}
return true;
}
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME = "reg" METHOD="post" ACTION="regsubmit.asp">
<TABLE ALIGN = "center" BORDER = "1">
<TR>
<TD COLSPAN = "3" ALIGN = "center">用户注册表单</TD>
</TR>
<TR>
<TD width="64" ALIGN = "right">用户名:</TD>
<TD width="89"><INPUT TYPE = "text" NAME = "username" size="10"></TD>
<TD width="90"><input type="button" name="Button" value="检测用户名" onClick="return Check();"></TD>
</TR>
<TR>
<TD ALIGN = "right">密码:</TD>
<TD colspan="2"><input type = "password" name = "password"></TD>
</TR>
<TR>
<TD ALIGN = "right">问题:</TD>
<TD colspan="2"><input name="question" type="text" id="question"></TD>
</TR>
<TR>
<TD ALIGN = "right">答案:</TD>
<TD colspan="2"><input name="answer" type="text" id="answer"></TD>
</TR>
<TR>
<TD ALIGN = "center"><INPUT TYPE = "submit" VALUE = "提交"
NAME = "btnSubmit"></TD>
<TD colspan="2" ALIGN = "center"><INPUT TYPE = "reset" VALUE = "全部重写"
NAME = "btnReset"></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
——————————regcheck.asp——————————————————
<%
Dim cnn, sSQL,dbpath,username,rs
username=request.QueryString("username")
Set cnn = Server.CreateObject("ADODB.Connection")
dbpath=server.mappath("test.mdb")
cnn.open"driver={microsoft access driver (*.mdb)};dbq="&dbpath
str="select * from webusers where username='"&username&"'"
set rs=server.CreateObject("adodb.recordset")
rs.open str,cnn
if rs.eof or rs.bof then
response.Write("<script language='javascript'>alert('恭喜!你还可以注册该帐号!')</script>")
else
response.Write("<script language='javascript'>alert('请另外选择用户名!')</script>")
end if
%>
以上程序是在表单提交前先判断用户所输入的用户名是否已经被别人注册。我的问题是:
怎样才能使得两个提示框(加粗的部分)能在reg.asp页面弹出来,而不是在regcheck.asp中弹出。我在response.writer语句后加了response.redirect("reg.asp"),虽然能跳回到reg.asp,但是却没有提示框弹出来了。这是为什么?请高人赐教!谢谢了