转 用户注册及输入框js检测范例(reg.asp)

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<SCRIPT language=JavaScript>

//校验xs_user的弹出窗口
function check_id_window(value){
window.open("check_id.asp?xs_user="+value,"",'toolbar=no,directories=no,scrollbars=0,resizable=1,status=no,menubar=0,width=250,height=100');
}

</SCRIPT>

<%
if session("xs_user")<>"" then
response.write "<script language='javascript'>"
response.write "alert('您已经是会员而且已经登录,无需重复注册!');"
response.write"this.location.href='../index.asp';</SCRIPT>"
response.end
else 
end if
%>
<script Language="JavaScript"> 
function FormCheck() 
{ 
if (trim(document.Form1.xs_user.value) =="")
{
alert("请填写您的登陆用户名!");
document.Form1.xs_user.focus();
return false;
}
var filter=/^\s*[A-Za-z0-9]{6,20}\s*$/;
if (!filter.test(document.Form1.xs_user.value)) { 
alert("用户名填写不正确,请重新填写!可使用的字符为(A-Z a-z 0-9)长度不小于6个字符,不超过20个字符,注意不要使用空格。"); 
document.Form1.xs_user.focus();
document.Form1.xs_user.select();
return false; 
} 
if (trim(document.Form1.xs_pass.value) =="") 
{
alert("请填写您的密码!");
document.Form1.xs_pass.focus();
return false; 
}
var filter=/^\s*[A-Za-z0-9]{6,20}\s*$/;
if (!filter.test(document.Form1.xs_pass.value)) { 
alert("密码填写不正确,请重新填写!可使用的字符为(A-Z a-z 0-9 )长度不小于6个字符,不超过20个字符,注意不要使用空格。"); 
document.Form1.xs_pass.focus();
document.Form1.xs_pass.select();
return false; 
}
if (trim(document.Form1.confirmpassword.value) =="") 
{
alert("请填写您的确认密码!");
document.Form1.confirmpassword.focus();
document.Form1.confirmpassword.select();
return false; 
}

if (document.Form1.xs_pass.value!=document.Form1.confirmpassword.value ){
alert("两次填写的密码不一致,请重新填写!"); 
document.Form1.xs_pass.focus();
document.Form1.xs_pass.select();
return false; 
} 
if (trim(document.Form1.xs_wenti.value) =="") 
{ 
alert("请选择密码提示问题!"); 
document.Form1.xs_wenti.focus(); 
return (false); 
} 
if (trim(document.Form1.xs_daan.value) =="") 
{ 
alert("请输入密码提示答案!"); 
document.Form1.xs_daan.focus(); 
return (false); 
} 
if (trim(document.Form1.xs_lxr.value) =="") 
{ 
alert("请输入您的真实姓名!"); 
document.Form1.xs_lxr.focus(); 
return (false); 
} 
if (trim(document.Form1.xs_mail.value) =="")
{
alert("请输入您的电子邮件地址!");
document.Form1.xs_mail.focus();
document.Form1.xs_mail.select();
return false;
}
var str1 = document.Form1.xs_mail.value
if(str1.indexOf("@") == -1 || str1.indexOf(".") == -1){ 
alert("E-mail格式不正确,请重新填写!"); 
document.Form1.xs_mail.focus();
document.Form1.xs_mail.select();
return false; 
} 
if (trim(document.Form1.xs_dh.value) =="") 
{ 
alert("请输入您的联系电话号码!"); 
document.Form1.xs_dh.focus(); 
return (false); 
}
if (trim(document.Form1.xs_dz.value) =="") 
{ 
alert("请输入您的联系地址!"); 
document.Form1.xs_dz.focus(); 
return (false); 
} 

if (trim(document.Form1.xs_gsjc.value) =="") 
{ 
alert("请输入贵公司的简称,如:“中国重汽”"); 
document.Form1.xs_gsjc.focus(); 
return (false); 
} 

if (trim(document.Form1.xs_gsqc.value) =="") 
{ 
alert("请输入贵公司的全称,如:“中国重型汽车集团有限公司”"); 
document.Form1.xs_gsqc.focus(); 
return (false); 
} 

if (trim(document.Form1.xs_khhmc.value) =="") 
{ 
alert("请输入您的开户行名称!"); 
document.Form1.khhmc.focus(); 
return (false); 
} 
if (trim(document.Form1.xs_yhzh.value) =="") 
{ 
alert("请输入您的银行帐号!"); 
document.Form1.xs_yhzh.focus(); 
return (false); 
} 
if (trim(document.Form1.xs_sh.value) =="") 
{ 
alert("请输入您的税号!"); 
document.Form1.xs_sh.focus(); 
return (false); 
} 
if (trim(document.Form1.xs_sj.value) =="") 
{ 
alert("请输入您的手机号码!"); 
document.Form1.xs_sj.focus(); 
return (false); 
} 
if (trim(document.Form1.xs_yb.value) =="") 
{ 
alert("请输入您的邮政编码!"); 
document.Form1.xs_yb.focus(); 
return (false); 
} 

document.Form1.submit()
}
//-->
//-->
function trim(inputString) {
    
               if (typeof inputString != "string") { return inputString; }
               var retValue = inputString;
               var ch = retValue.substring(0, 1);
               while (ch == " ") { 
            //检查字符串开始部分的空格
                   retValue = retValue.substring(1, retValue.length);
                   ch = retValue.substring(0, 1);
               }
               ch = retValue.substring(retValue.length-1, retValue.length);
               while (ch == " ") {
                  //检查字符串结束部分的空格
                  retValue = retValue.substring(0, retValue.length-1);
                  ch = retValue.substring(retValue.length-1, retValue.length);
               }
               while (retValue.indexOf("   ") != -1) { 
           //将文字中间多个相连的空格变为一个空格
                  retValue = retValue.substring(0, retValue.indexOf("   ")) + retValue.substring(retValue.indexOf("   ")+1, retValue.length); 
               }
               return retValue;
            } 

//--> 
</script>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>客户注册</title>
<link href="../css.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.STYLE1 {color: #FF0000}
.STYLE2 {color: #000000}
body,td,th {
font-size: 12px;
}
-->
</style>
</head>

<body leftmargin="0" topmargin="0">
<table width="780" border="0" cellpadding="0" cellspacing="1" align="center" bgcolor="#eeeeee">
   <!--DWLayoutTable-->
   <tr>
     <td width="778" height="232"> </td>
   </tr>
  
   <tr>
     <td height="5" valign="top"><img name="" src="" width="32" height="5" alt="" /></td>
   </tr>
   <tr>
     <td height="441" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
       <!--DWLayoutTable-->
       <tr>
         <td height="43" colspan="2" align="center" valign="middle"><p><span class="STYLE1">注意</span>:请认真填写您的真实资料,我们将在1个工作日内对您的资料进行审核并开通您的会员资格;<span class="STYLE1">*</span>号标注的为必添内容。</p>
             <p><br />
               <br />
             </p></td>
         </tr>
   <FORM name="Form1" action="register_confirm.asp" method="post">
       <tr>
         <td width="147" height="21" align="right" valign="middle">登陆用户名:</td>
           <td width="633" valign="middle"><input name="xs_user" size="15" maxlength="20" />
             <input class="buttons" onClick="check_id_window(document.Form1.xs_user.value)" type="button" value="检测该帐号是否已被注册" name="Check_ID" />
           <span class="STYLE1">           *</span>   6-20位英文大小写字母或数字</td>
         </tr>
       <tr>
         <td height="20" align="right" valign="middle">设置登陆密码:</td>
           <td valign="middle"><input type="password" maxlength="20" size="22" name="xs_pass" />
           <span class="STYLE1">*</span> 6-20位英文大小写字母或数字,区分大小写</td>
         </tr>
       <tr>
         <td height="20" align="right" valign="middle">再次输入密码:</td>
           <td valign="middle"><input type="password" maxlength="20" size="22" name="confirmpassword" /></td>
         </tr>
       <tr>
         <td height="20" align="right" valign="middle">密码提示问题:</td>
           <td valign="middle"><select size="1" name="xs_wenti">
             <option value="">请选择任一问题</option>
             <option value="你在哪所中学读初中?">你在哪所中学读初中?</option>
             <option value="你出生的城市是什么?" selected="selected">你出生的城市是什么?</option>
             <option value="你最喜欢的音乐是?">你最喜欢的音乐是?</option>
             <option value="你最喜欢的球队是?">你最喜欢的球队是?</option>
             <option value="你最喜欢的书是?">你最喜欢的书是?</option>
             <option value="你最好的朋友是?">你最好的朋友是?</option>
             <option value="你的出生年月是?">你的出生年月是?</option>
             <option value="你爱人的名字是?">你爱人的名字是?</option>
             <option value="你父亲的名字是?">你父亲的名字是?</option>
             <option value="你母亲的名字是?">你母亲的名字是?</option>
           </select>
           <span class="STYLE1">*</span></td>
         </tr>
       <tr>
         <td height="20" align="right" valign="middle">密码提示答案:</td>
           <td valign="middle"><input maxlength="100" size="22" name="xs_daan" />
           <span class="STYLE1">*<span class="STYLE2"> 请牢记您输入的答案,如果您不慎忘记密码,可以通过它找回</span></span></td>
         </tr>
      
       <tr>
         <td height="20" align="right" valign="middle">公司简称:</td>
           <td valign="middle"><span class="S S">
             <input maxlength="50" size="22" name="xs_gsjc" />
             <span class="STYLE1">* <span class="STYLE2">如:中国重汽</span></span></span></td>
         </tr>
       <tr>
         <td height="20" align="right" valign="middle">公司全称:</td>
           <td valign="middle"><span class="S S">
             <input maxlength="100" name="xs_gsqc" size="22" />
             <span class="STYLE1">* <span class="STYLE2">如:中国重型汽车集团有限公司</span></span></span></td>
         </tr>
       <tr>
         <td height="20" align="right" valign="middle">开户行:</td>
           <td valign="middle"><input name="xs_khhmc" size="22" maxlength="100" />
           <span class="S S"> <span class="STYLE1">*</span></span></td>
         </tr>
       <tr>
         <td height="20" align="right" valign="middle">银行帐号:</td>
           <td valign="middle"><input name="xs_yhzh" size="22" maxlength="100" />
           <span class="S S"> <span class="STYLE1">*</span></span></td>
         </tr>
       <tr>
         <td height="20" align="right" valign="middle">税号:</td>
           <td valign="middle"><span class="S S">
             <input name="xs_sh" size="22" />
           <span class="STYLE1">*</span></span></td>
         </tr>
       <tr>
         <td height="20" align="right" valign="middle">联系人姓名:</td>
           <td valign="middle"><span class="S S">
             <input maxlength="20" size="22" name="xs_lxr" />
             <span class="STYLE1">*</span></span></td>
         </tr>
       <tr>
         <td height="20" align="right" valign="middle">性别:</td>
           <td valign="middle"><input type="radio" value="先生" name="xs_xb" checked="checked" />
             <font class="f2">先生  </font>
             <input type="radio" value="女士" name="xs_xb" />
             <font class="f2">女士     <span class="STYLE1">*</span></font></td>
         </tr>
       <tr>
         <td height="20" align="right" valign="middle">固定电话:</td>
           <td valign="middle"><input name="xs_dh" size="22" />
           <span class="STYLE1">*</span></td>
         </tr>
       <tr>
         <td height="20" align="right" valign="middle">手机:</td>
           <td valign="middle"><span class="S S">
             <input name="xs_sj" size="22" />
             <span class="STYLE1">*</span></span></td>
         </tr>
       <tr>
         <td height="20" align="right" valign="middle">地址:</td>
           <td valign="middle"><span class="S S">
             <input maxlength="100" size="35" name="xs_dz" />
             <span class="STYLE1">*</span></span></td>
         </tr>
       <tr>
         <td height="20" align="right" valign="middle">电子邮箱:</td>
           <td valign="middle"><input name="xs_mail" id="xs_mail" size="22" maxlength="50" />
           <span class="STYLE1">*</span></td>
         </tr>
       <tr>
         <td height="20" align="right" valign="middle">邮政编码:</td>
           <td valign="middle"><span class="S S">
             <input maxlength="10" size="22" name="xs_yb" />
             <span class="STYLE1">*</span></span></td>
         </tr>
       <tr>
         <td height="58" colspan="2" align="center" valign="middle"><p><a href="xieyi.asp" target="_blank"><br />
         </a><br />
           <br />
           <input name="button" type="button" onClick="FormCheck()" value="确认注册" />
             
           <input type="reset" name="Submit" value="取消重添" />
         </p></td>
         </tr>
   </FORM>
     </table></td>
   </tr>
   <tr>
     <td height="5" valign="top"><img name="" src="" width="32" height="5" alt="" /></td>
   </tr>
   <tr>
     <td height="63" align="center"><hr /></td>
   </tr>
</table>
</body>
</html>
posted on 2011-08-11 09:36  yjheimi  阅读(463)  评论(0编辑  收藏  举报