回 帖 发 新 帖 刷新版面

主题:求助[表单提交]

大侠帮个忙,这是个注册页面,在提交之前,先检测一下用户数据输入是否规范,可是现在检测不了了,提交的数据没有任何反应...


<script language=vbscript>

<!--
  sub tijiao_onclick()
  if len(login.userid.value)<3 then
  msgbox"用户名太短,请选择一个大于3的名字"
  login.userid.select
  exit sub 
  end if 
  
  
  if instr(trim(login.userid.value),"")>1 then
  msgbox"用户名中请不要加入空格"
  login.userid.select
  exit sub
  end if 
  
  if len(login.userpw.value)<4 then
  msgbox"密码太短,请选择一个长度大于4的密码"
  login.userpw.select
  exit sub
  end if 
  
  if login.userpw.value<>login.verifypw.value then
  msgbox "确认密码和密码不同,请确认"
  login.userpw.value=""
  login.verifypw.value=""
  login.userpw.select
  exit sub
  end if 
  
  if login.name.value="" then
  msgbox"为了更好的为您服务,请输入您的名字"
  login.name.select
  exit sub
  end if 
  
  if login.idnumber.value="" or not isnumeric(login.idnumber.value) or len(login.idnumber.value)<>15 and len(login.idnumber.value)<>18 then
  msgbox"请正确输入您的身份证号码"
  login.idnumber.select
  exit sub
  end if 
  
  if login.age.value="" or not isnumeric(login.age.value) then
  msgbox"请正确输入您的年龄"
  login.age.select
  exit sub
  else
  
  if cint(login.age.value)<12 then
  msgbox"年龄输入范围有错"
  login.age.select
  exit sub
  end if 
  
  if login.address.value="" then
  msgbox"请输入您的详细联系地址"
  login.address.select
  exit sub 
  end if
  
  if len(login.zipcode.value)<>6 or NOT isnumeric(login.zipcode.value) then
  msbgox"邮政编码输入有误,请更正!"
  login.zipcode.select
  exit sub 
  end if 
  
  if not login.phone.value="" then  
  if isnumeric(login.phone.value) then
  if len(login.phone.value)>7 or left(login.phone.value,1)="-" or left(login.phone.value,1)="+" then
  msbbox"电话号码输入有误"
  login.phone.select
  exit sub
  end if
  
  
  else  
  pos=instr(login.phone.value,"-")
  len_phone=len(login.phone.value)
  if pos>1 and pos<len-phone then
  lef=left(login.phone.value.pos-1)
  rig=right(login.phone.value,len_phone-pos)
  if not isnumeric(lef) or not isnumeric(rig) or len(rig)<5 then
  msgbox"电话号码输入有误"
  login.phone.select
  exit sub
  end if 
  end if 
  end if 
  
  if login.email.value="" then
  msgbox"为了与您方便的联系,请e-mail地址"
  login.email.select
  exit sub
  
  else
  if not right(login.email.value,4)=".com" and not right(login.email.value,4)=".net" and not right(login.email.value,3)=".cn" or instr(login.email.value,"@")<=1 or instr(login.email.value,"@.") then
  msgbox"请正确的输入您的E-mail"
  login.email.select
  exit sub
  end if 
  end if 
  login.submit
  end sub
  -->
  </script> 
  <html>
  <head>
  <meta http-equiv="content-language" content="THL">
  <meta http-equiv="content-type" content="text/html;charset=gb2312">
  <style type="text/css">
  <!-- 
  .style5{font-size:12}
  .style6{color:#ff0000}
  -->  
  </style>  
  </head>
   
  <body leftmargin="50" class="class2">
  <span class="style5">您的位置:注册页面 注意:带*的项目为必填项目  </span>
  <hr />
  <form action="cutadd.asp" method="post" name="form1" class="style5" id="form1">
    <p>会 员 名:
      <input name="userid" type="text" id="userid" size="20" maxlength="20" />
    *(用户名长度为3-8位)</p>
    <p>密  码:
      <input name="userpw" type="password" id="userpw" size="20" maxlength="20" />
    *(密码长度为4-8位)</p>
    <p>确认密码:
      <input name="verifypw" type="password" id="verifypw" size="20" maxlength="20" />
    *</p>
    <p>您的姓名:
      <input name="name" type="text" id="name" size="20" maxlength="20" />
    *</p>
    <p>身份证号:
      <input name="idnumber" type="text" id="idnumber" size="35" maxlength="20" />
    *</p>
    <p>性  别:
      <input type="radio" name="sex" value="男" />
      男
      <input type="radio" name="sex" value="女" />
      女
    *</p>
    <p>您的年龄:
      <input name="age" type="text" id="age" size="5" maxlength="5" />
    *</p>
    <p>详细地址:
      <input name="address" type="text" id="address" size="35" maxlength="50" />
    *</p>
    <p>邮政编码:
      <input name="zipcode" type="text" id="zipcode" size="10" maxlength="6" />
    *</p>
    <p>电话号码:
      <input name="phone" type="text" id="phone" size="20" maxlength="20" />
    </p>
    <p>电子邮箱:
      <input name="email" type="text" id="email" size="20" maxlength="20" />
    *</p>
    <p>
      <input type="button" name="tijiao" value="提交" >
      <input type="reset" name="Submit2" value="重置">
      
    </p>
  </form>
  <p>&nbsp;</p>
  </body>
  
  </html>
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  [em1][em2][em2]

回复列表 (共10个回复)

沙发

坐等...

板凳

本来你就没控制 

在提交按纽里面加上 onclick="return tijiao_onclick()"

3 楼

有两处要改:
 <form action="cutadd.asp" method="post" name="form1" class="style5" id="form1">
改成
 <form action="cutadd.asp" method="post" name="login" class="style5" id="login">

--------------------------------------------------------------
<input type="button" name="tijiao" value="提交" >改成:
<input type="button" name="tijiao" value="提交" onClick="tijiao_onclick()">

4 楼

多谢楼上的

可是我加进去了,系统还是报错 有两处:

行:104
字符:7
代码:0
错误:缺少 'If'
网址:http://localhost/shop/enroll.asp

行:162
字符:1
代码:0
错误:类型不匹配: 'tijiao_onclick'
网址:http://localhost/shop/enroll.asp

5 楼

if not login.phone.value="" then  
  if isnumeric(login.phone.value) then
  if len(login.phone.value)>7 or left(login.phone.value,1)="-" or left(login.phone.value,1)="+" then
  msbbox"电话号码输入有误"
  login.phone.select
  exit sub
  end if
  
  
  else  
  pos=instr(login.phone.value,"-")
  len_phone=len(login.phone.value)
  if pos>1 and pos<len-phone then
  lef=left(login.phone.value.pos-1)
  rig=right(login.phone.value,len_phone-pos)
  if not isnumeric(lef) or not isnumeric(rig) or len(rig)<5 then
  msgbox"电话号码输入有误"
  login.phone.select
  exit sub
  end if 
  end if 
  end if 
在尾部再加一个end if(少了个end if你仔细看看)

6 楼

嗯, 我把那个end if 加进去了


系统这样提示

行:98
字符:7
代码:0
错误:缺少 'Sub'
网址:http://localhost/shop/enroll.asp

7 楼

第98行的代码是什么?

8 楼

里面什么都没有,就是刚加的end if 后面的一行

9 楼

在end if之间均加个exit sub
还有最好改成:
onClick="vbscript:call tijiao_onclick()">

10 楼

OK,又测试了一下,
可以用了,感谢


十分感谢

[帮助他人是一种快乐;当然自己也可能会碰上困难,这个时候得到他人帮助是一种幸福。]

谢谢你


我来回复

您尚未登录,请登录后再回复。点此登录或注册