HTML制作网页表单验证代码

合集下载
相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
{ flagSZ=true}
else
{ flagQT=true}
}
if(!flagZM||!flagSZ||flagQT){
divpassword1.innerHTML="<font color=red>密码必须是字母数字的组合</font>"
return false;
}
else
divpassword1.innerHTML="<font color='green'>输入正确</font>"
//定义了城市的二维数组,里面的顺序跟省份的顺序是相同的。通过selectedIndex获得省份的下标值来得到相应的城市数组
var city=[
["北京","天津","上海","重庆","香港","澳门"],
["石家庄","唐山","秦皇岛","邯郸","邢台","保定","张家口","承德","沧州","廊坊","衡水"],
["西安","铜川","宝鸡","咸阳","渭南","延安","汉中","榆林","安康","商洛"],
["兰州","白银","定西","敦煌","嘉峪关","金昌","天水","武威","张掖","平凉","酒泉","庆阳","临夏","陇南","甘南"],
["西宁","海东","海北","黄南","海南","果洛","玉树","海西"],
["太原","大同","阳泉","长治","晋城","朔州","晋中","运城","忻州","临汾","吕梁"],
["呼和浩特","包头","乌海","赤峰","通辽","鄂尔多斯","呼伦贝尔","巴彦淖尔","乌兰察布","兴安","锡林郭勒","阿拉善"],
["沈阳","大连","鞍山","抚顺","本溪","丹东","锦州","营口","阜新","辽阳","盘锦","铁岭","朝阳","葫芦岛"],
if (document.form1.textmail.value.charAt(0)=="." || document.form1.textmail.value.charAt(0)=="@"|| document.form1.textmail.value.indexOf(’@’, 0) == -1 || document.form1.textmail.value.indexOf(’.’, 0) == -1 || document.form1.textmail.value.lastIndexOf("@")==document.form1.textmail.value.length-1 || document.form1.textmail.value.lastIndexOf(".")==document.form1.textmail.value.length-1)
表单验证代码html表单验证html网页跳转代码html网页代码html网页空格代码html网页特效代码html网页导航代码html网页模板源代码html网页设计源代码表单验证
HTML制作网页表单验证代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<script language="javascript">
//验证密码
function checkpsd1(){
//div11=document.getElementById("divpassword1");
psd1=form1.textpassword1.value;
var flagZM=false
}
}
</script>
<script language="javascript">
//验证复选框
function checknum(){
var s="";
for (var i=0;i< document.form1.box.length;i++)
{
//判断第i个复选框是否被选中
if (document.form1.box[i].checked==true)
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>用户名注册</title>
<script language="javascript">
["长春","吉林","四平","辽源","通化","白山","松原","白城","延边"],
["哈尔滨","齐齐哈尔","鸡西","鹤岗","双鸭山","大庆","伊春","佳木斯","七台河","牡丹江","黑河","绥化","大兴安岭"],
["南京","苏州","扬州","无锡","徐州","常州","南通","连云港","淮安","盐城","镇江","泰州","宿迁"],
["南昌","上饶","萍乡","九江","景德镇","新余","鹰潭","赣州","吉安","宜春","抚州"],
["济南","青岛","淄博","枣庄","东营","烟台","潍坊","威海","济宁","泰安","日照","莱芜","临沂","德州","聊城","滨州","菏泽"],
["郑州","开封","洛阳","平顶山","焦作","鹤壁","新乡","安阳","濮阳","漯河","许昌","三门峡","南阳","商丘","信阳","周口","驻马店"],
//验证文本框
function checkarea(){
area=form1.textarea.value;
if(area.length<10)
{
divarea.innerHTML="<font color=red>请输入至少十个字符</font>"
}
else
{
divarea.innerHTML="<font color='green'>输入正确</font>"
["杭州","宁波","温州","嘉兴","湖州","绍兴","金华","衢州","舟山","台州","丽水"],
["合肥","芜湖","蚌埠","淮南","马鞍山","淮北","铜陵","安庆","黄山","滁州","阜阳","宿州","巢湖","六安","亳州","池州","宣城"],
["福州","宁德","南平","厦门","莆田","三明","泉州","漳州"],
flag=false;
}
return flag;
//return true;
}
</script>
<script language="javascript">
//验证用户名
function checkna()
{
var na=form1.textname.value;
if(na.length<6 || na.length>12)
["武汉","十堰","襄樊","鄂州","黄石","荆州","宜昌","荆门","孝感","黄冈","咸宁","随州","恩施"],
["长沙","株洲","湘潭","岳阳","邵阳","常德","衡阳","张家界","益阳","郴州","永州","怀化","娄底","湘西"],
["广州","清远","潮州","东莞","珠海","深圳","汕头","韶关","佛山","江门","湛江","茂名","肇庆","惠州","梅州","汕尾","阳江","河源","中山","揭阳","云浮"],
["贵阳","六盘水","遵义","安顺","铜仁","毕节","黔西南","黔东南","黔南"],
["昆明","曲靖","玉溪","保山","昭通","丽江","普洱","临沧","文山","红河","西双版纳","楚雄","大理","德宏","怒江","迪庆"],
["拉萨","昌都","山南","日喀则","那曲","阿里","林芝"],
return true;
}
return true;
}
//-->
</script>
<script language="javascript">
//验证确认密码
funwenku.baidu.comtion checkpsd2(){
if(form1.textpassword1.value!=form1.textpassword2.value)
{
divmail.innerHTML="<font color=red>Email的格式不正确!</font>"
return false;
}
else
divmail.innerHTML="<font color=red>输入正确</font>"
return true;
}
</script>
<script type="text/javascript">
{
divname.innerHTML="<font color=red>长度错误</font>"
return false;
}
else
{
divname.innerHTML="<font color='green'>输入正确</font>"
return true;
}
return true;
}
</script>
s=s+document.form1.box[i].value+"\n";
}
else if(s<2)
divbox.innerHTML="<font color='red'>请选择两个以上</font>"
}
</script>
<script language="javascript">
//验证邮箱
function checkmail(){
{
if((psd1.charAt(i) >= 'A' && psd1.charAt(i)<='Z') || (psd1.charAt(i)>='a' && psd1.charAt(i)<='z'))
flagZM=true
else if(psd1.charAt(i)>='0' && psd1.charAt(i)<='9')
var flagSZ=false
var flagQT=false
if(psd1.length<6 || psd1.length>12){
divpassword1.innerHTML="<font color=red>长度错误</font>"
return false;
}
else
{
for(i=0;i < psd1.length;i++)
["银川","石嘴山","吴忠","固原","中卫"],
["乌鲁木齐","克拉玛依","吐鲁番","哈密","和田","阿克苏","喀什","克孜勒苏柯尔克孜","巴音郭楞蒙古","昌吉","博尔塔拉蒙古","伊犁哈萨克","阿勒泰"],
{
divpassword2.innerHTML="<font color=red>您两次输入的密码不一样</font>"
}
else
divpassword2.innerHTML="<font color='green'>输入正确</font>"
}
</script>
<script language="javascript">
divpassword1.innerHTML="<font color=red>请输入密码</font>"
flag=false;
//return false
}
if(form1.textpassword2.value==""){
divpassword2.innerHTML="<font color=red>请再次输入密码</font>"
//验证表单是否为空
function checkForm(){
var flag=true;
if(form1.textname.value==""){
divname.innerHTML="<font color=red>请输入用户名</font>"
flag=false;
//return false
}
if(form1.textpassword1.value==""){
flag=false;
//return false
}
if(form1.textarea.value==""){
divarea.innerHTML="<font color=red>请输入您的简历</font>"
flag=false;
}
if(form1.textmail.value==""){
divmail.innerHTML="<font color=red>请输入您的邮箱</font>"
["南宁","柳州","桂林","梧州","北海","防城港","钦州","贵港","玉林","百色","贺州","河池","来宾","崇左"],
["海口","三亚"],
["成都","自贡","攀枝花","泸州","德阳","绵阳","广元","遂宁","内江","乐山","南充","宜宾","广安","达州","眉山","雅安","巴中","资阳","阿坝","甘孜","凉山"],
相关文档
最新文档