vbscript代码判断email格式是否正确
怎么用vbscript代码判断用户的email格式是否正确ifform1.useremail.value=(这一句具体怎么写才能判断出email其中有没有@?)thena...
怎么用vbscript代码判断用户的email格式是否正确
if form1.useremail.value=(这一句具体怎么写才能判断出email其中有没有@?) then
alert("email 格式不正确")
end if 展开
if form1.useremail.value=(这一句具体怎么写才能判断出email其中有没有@?) then
alert("email 格式不正确")
end if 展开
展开全部
<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
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
msgbox "邮政编码输入有误,请更正"
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
msgbox "电话号码输入有误"
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
else
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>
自己选吧
<!--
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
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
msgbox "邮政编码输入有误,请更正"
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
msgbox "电话号码输入有误"
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
else
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>
自己选吧
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询