<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" onfocus="ValidateFrom(this,0)" onblur="ValidateFcode();" ></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
%>