| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 797 人关注过本帖
标题:如何进行客户端onclick验证?
只看楼主 加入收藏
labid
Rank: 1
等 级:新手上路
帖 子:151
专家分:0
注 册:2006-6-20
收藏
 问题点数:0 回复次数:6 
如何进行客户端onclick验证?

<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.userid.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
end if

if login.address.value="" then
msgbox"请输入您的详细地址"
login.address.select
exit sub
end if

if len(login.zipcode.value)<>6 Not isnumberic(login.zipcode.value) then
msgbox"邮政编码输入有误,请更正"
login.zipcode.select
exit.sub
end if

if not login.phone.value="" then
if isnumberic(login.phone.value) then
if len(login.phone.value)<7 or left(login.phone.value,1)="-" or left(login.phone.value,1)="+" then
msgbox"电话号码输入有错1"
login.phone.select
exit.sub
end if
else
pos=insrt(login.phone.value,"-")
len_phone=len(login.phone.value)
if pos>1 and pos<len_phone then
lef=letf(login.phone.value,pos-1)
rig=right(login.phone.value,len_phone)
if not isnumberic(lef) or notisnumbeic(rig) or len(rig)<5 then
msgbox "电话号码有错误2"
login.phone.select
exit sub
end if
else
msgbox"电话号码有错3"
login.phone.select
exit sub
end if
end if
end if

if login.email.value="" then
msegbox "为了你的方便,请出入油箱"
login.emali.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,4)=".cn" or instr(login.email.value,"@")<=1 or instr(login.emali.value,"@.") then
msgbox"请正确输入你的幽香"
login.email.select
exit sub
end if
end if
login.submit
end sub
-->
</script>
<html>
<head>

<title>注册新会员</title>
<meta http-equiv="conten-language" content="THL">
<meta http-equiv="conten-type" content="text/html;charset=gb2312">
<style type="text/css">
<!--
.style5 {font-size:big}
.style6 {color:#ff0000}
-->
</style>
</head>
<body leftmargin=20 class=class2>
<span class="style5"><font color="#ff0000">你的位置:注册页面&nbsp;&nbsp;&nbsp;注意:带*是必填项目</font></span>
<br>
<hr color="#999933" size=1>

<form method="post" action="custadd.asp" name="login">
<p class=style5>
会员名:
<input type="text" name="userid" size="15" maxlength="8" class=style5>
<span class="style6">*</span>(用户名字长度为3-8位)<br>
<br>
密码:
<input type="password" name="userpw" size="15" maxlength="8" class=style5>
<span class="style6">*</span>(用户名字长度为4-8位)<br>
<br>
确认密码:
<input type="password" name="verifypw" size="15" class=style5>
<span class="style6">*</span><br>
<br>
你的姓名:
<input type="text" name="name" size="15" maxlength="8" class=style5>
<span class="style6">*</span><br>
<br>
身份验证:<input type="text" name="idnumber" size="20" maxlength="18" class=style5>
<span class="style6">*</span><br>
<br>
性别:
   <input name="sex" type="radio" class=style5 value="男" checked>

   <input name="sex" type="radio" class=style5 value"女">

<span class="style6">*</span><br>
<br>
你的年龄:
<input type="text" name="age" size="5" maxlength="2" class=style5>
<span class="style6">*</span><br>
<br>
详细地址:
<input type="text" name="address" size="20" maxlength="6" class=style5>
<span class="style6">*</span><br>
<br>
邮政编码:<input type="text" name="zipcode" size="20" maxlength="6" class=style5>
<span class="style6">*</span><br>
<br>
电话号码:
<input type="text" name="phone" size="20" class=style5>
<br>
电子邮箱:
<input type="text" name="email" type="text" class=style5 size="20" maxlength="30">
<span class="style6">*</span><br>
<br>
<input name="tijiao" type="button" class="style5" value="提交">
<input name="zhongzhi" type="reset" class="style5" value="重填">
</p>
</form>
</body>
</html>

哪位高手帮我改改,怎么点了提交,不进行脚本验证!谢谢

搜索更多相关主题的帖子: onclick login 客户端 userid 
2006-06-23 00:17
google
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:22
帖 子:3419
专家分:23
注 册:2005-11-1
收藏
得分:0 
login.userid.value,这个应该只的是这个ID的数值,而不是长度,我个人理解
VBSCRIPT的判断我不会
不过JAVASCRIPT的是login.userid.value.length

祝天下所有母亲幸福安康!~
2006-06-23 00:57
labid
Rank: 1
等 级:新手上路
帖 子:151
专家分:0
注 册:2006-6-20
收藏
得分:0 
谢谢姐姐````!55555
但是我要VB的答案,要不姐姐给我发个JS的初级教程,我去学学,我以后用JS算了!我都弄了一天了!
555555555555555555555555555555!
2006-06-23 01:29
hangxj
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:2045
专家分:0
注 册:2006-4-10
收藏
得分:0 
<input name="tijiao" type="button" class="style5" onclick="tijiao_onclick()" value="提交">

http://www./
2006-06-23 08:52
huyuntao
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2006-6-15
收藏
得分:0 

我写的一个通用的js验证
<script language="javascript">
function CheckAdd(){
MsgBox=new Array()
MsgBox[0]=new Array("TiTle","栏目标题不能为空!")
MsgBox[1]=new Array("Type","栏目类型不能为空!")
MsgBox[2]=new Array("Temp","栏目模板不能为空!")
for(i=0;i<MsgBox.length;i++){
if(document.all[MsgBox[i][0]].value==''){
alert(MsgBox[i][1]);
document.all[MsgBox[i][0]].focus();
return false;
}
}
}
</script>
MsgBox[0]=new Array(1,2)
1代表控件的名称,2代表提示的信息

2006-06-23 10:22
guixiaolan
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:356
专家分:0
注 册:2006-4-20
收藏
得分:0 
将msgbox改成alert 试试

[url=http://www./]/sign/free.gif" target="_blank">http://ip./sign/free.gif[/url]
2006-06-23 11:20
labid
Rank: 1
等 级:新手上路
帖 子:151
专家分:0
注 册:2006-6-20
收藏
得分:0 
谢谢各位大哥``问题已经解决了~~~~~!
我一个一个判断的排处!结果有2个判断书写上有错,为什么IIS```不提示错误啊!害我弄了一天~!
终于睡得着了``睡觉去了!
2006-06-23 13:43
快速回复:如何进行客户端onclick验证?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015632 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved