HTML制作網(wǎng)頁(yè)表單驗(yàn)證代碼_第1頁(yè)
HTML制作網(wǎng)頁(yè)表單驗(yàn)證代碼_第2頁(yè)
HTML制作網(wǎng)頁(yè)表單驗(yàn)證代碼_第3頁(yè)
HTML制作網(wǎng)頁(yè)表單驗(yàn)證代碼_第4頁(yè)
HTML制作網(wǎng)頁(yè)表單驗(yàn)證代碼_第5頁(yè)
已閱讀5頁(yè),還剩5頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

HTML制作網(wǎng)頁(yè)表單驗(yàn)證代碼<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN""/TR/html4/loose.dtd"><html><head><metahttp-equiv="Content-Type"content="text/html;charset=gb2312"><title>用戶(hù)名注冊(cè)</title><scriptlanguage="javascript">//驗(yàn)證表單是否為空f(shuō)unctioncheckForm(){varflag=true;if(form1.textname.value==""){ divname.innerHTML="<fontcolor=red>請(qǐng)輸入用戶(hù)名</font>" flag=false; //returnfalse}if(form1.textpassword1.value==""){ divpassword1.innerHTML="<fontcolor=red>請(qǐng)輸入密碼</font>" flag=false; //returnfalse}if(form1.textpassword2.value==""){ divpassword2.innerHTML="<fontcolor=red>請(qǐng)?jiān)俅屋斎朊艽a</font>" flag=false; //returnfalse}if(form1.textarea.value==""){divarea.innerHTML="<fontcolor=red>請(qǐng)輸入您的簡(jiǎn)歷</font>"flag=false; } if(form1.textmail.value==""){divmail.innerHTML="<fontcolor=red>請(qǐng)輸入您的郵箱</font>"flag=false;} returnflag;//returntrue;}</script><scriptlanguage="javascript">//驗(yàn)證用戶(hù)名functioncheckna(){varna=form1.textname.value;if(na.length<6||na.length>12){ divname.innerHTML="<fontcolor=red>長(zhǎng)度錯(cuò)誤</font>" returnfalse;} else { divname.innerHTML="<fontcolor='green'>輸入正確</font>" returntrue;}returntrue;}</script><scriptlanguage="javascript">//驗(yàn)證密碼functioncheckpsd1(){ //div11=document.getElementById("divpassword1"); psd1=form1.textpassword1.value; varflagZM=false varflagSZ=false varflagQT=false if(psd1.length<6||psd1.length>12){ divpassword1.innerHTML="<fontcolor=red>長(zhǎng)度錯(cuò)誤</font>" returnfalse; } else { for(i=0;i<psd1.length;i++) { if((psd1.charAt(i)>='A'&&psd1.charAt(i)<='Z')||(psd1.charAt(i)>='a'&&psd1.charAt(i)<='z')) flagZM=true elseif(psd1.charAt(i)>='0'&&psd1.charAt(i)<='9') {flagSZ=true} else {flagQT=true} } if(!flagZM||!flagSZ||flagQT){ divpassword1.innerHTML="<fontcolor=red>密碼必須是字母數(shù)字的組合</font>" returnfalse; } else divpassword1.innerHTML="<fontcolor='green'>輸入正確</font>" returntrue; } returntrue;}//--></script><scriptlanguage="javascript">//驗(yàn)證確認(rèn)密碼functioncheckpsd2(){if(form1.textpassword1.value!=form1.textpassword2.value){divpassword2.innerHTML="<fontcolor=red>您兩次輸入的密碼不一樣</font>"}elsedivpassword2.innerHTML="<fontcolor='green'>輸入正確</font>"}</script><scriptlanguage="javascript">//驗(yàn)證文本框functioncheckarea(){area=form1.textarea.value;if(area.length<10){ divarea.innerHTML="<fontcolor=red>請(qǐng)輸入至少十個(gè)字符</font>"} else { divarea.innerHTML="<fontcolor='green'>輸入正確</font>" }}</script><scriptlanguage="javascript">//驗(yàn)證復(fù)選框functionchecknum(){vars="";for(vari=0;i<document.form1.box.length;i++){//判斷第i個(gè)復(fù)選框是否被選中if(document.form1.box[i].checked==true)s=s+document.form1.box[i].value+"\n";}elseif(s<2)divbox.innerHTML="<fontcolor='red'>請(qǐng)選擇兩個(gè)以上</font>"}</script><scriptlanguage="javascript">//驗(yàn)證郵箱functioncheckmail(){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){divmail.innerHTML="<fontcolor=red>Email的格式不正確!</font>"returnfalse;}elsedivmail.innerHTML="<fontcolor=red>輸入正確</font>"returntrue;}</script><scripttype="text/javascript">//定義了城市的二維數(shù)組,里面的順序跟省份的順序是相同的。通過(guò)selectedIndex獲得省份的下標(biāo)值來(lái)得到相應(yīng)的城市數(shù)組varcity=[["北京","天津","上海","重慶","香港","澳門(mén)"],["石家莊","唐山","秦皇島","邯鄲","邢臺(tái)","保定","張家口","承德","滄州","廊坊","衡水"],["太原","大同","陽(yáng)泉","長(zhǎng)治","晉城","朔州","晉中","運(yùn)城","忻州","臨汾","呂梁"],["呼和浩特","包頭","烏海","赤峰","通遼","鄂爾多斯","呼倫貝爾","巴彥淖爾","烏蘭察布","興安","錫林郭勒","阿拉善"],["沈陽(yáng)","大連","鞍山","撫順","本溪","丹東","錦州","營(yíng)口","阜新","遼陽(yáng)","盤(pán)錦","鐵嶺","朝陽(yáng)","葫蘆島"],["長(zhǎng)春","吉林","四平","遼源","通化","白山","松原","白城","延邊"],["哈爾濱","齊齊哈爾","雞西","鶴崗","雙鴨山","大慶","伊春","佳木斯","七臺(tái)河","牡丹江","黑河","綏化","大興安嶺"],["南京","蘇州","揚(yáng)州","無(wú)錫","徐州","常州","南通","連云港","淮安","鹽城","鎮(zhèn)江","泰州","宿遷"],["杭州","寧波","溫州","嘉興","湖州","紹興","金華","衢州","舟山","臺(tái)州","麗水"],["合肥","蕪湖","蚌埠","淮南","馬鞍山","淮北","銅陵","安慶","黃山","滁州","阜陽(yáng)","宿州","巢湖","六安","亳州","池州","宣城"],["福州","寧德","南平","廈門(mén)","莆田","三明","泉州","漳州"],["南昌","上饒","萍鄉(xiāng)","九江","景德鎮(zhèn)","新余","鷹潭","贛州","吉安","宜春","撫州"],["濟(jì)南","青島","淄博","棗莊","東營(yíng)","煙臺(tái)","濰坊","威海","濟(jì)寧","泰安","日照","萊蕪","臨沂","德州","聊城","濱州","菏澤"],["鄭州","開(kāi)封","洛陽(yáng)","平頂山","焦作","鶴壁","新鄉(xiāng)","安陽(yáng)","濮陽(yáng)","漯河","許昌","三門(mén)峽","南陽(yáng)","商丘","信陽(yáng)","周口","駐馬店"],["武漢","十堰","襄樊","鄂州","黃石","荊州","宜昌","荊門(mén)","孝感","黃岡","咸寧","隨州","恩施"],["長(zhǎng)沙","株洲","湘潭","岳陽(yáng)","邵陽(yáng)","常德","衡陽(yáng)","張家界","益陽(yáng)","郴州","永州","懷化","婁底","湘西"],["廣州","清遠(yuǎn)","潮州","東莞","珠海","深圳","汕頭","韶關(guān)","佛山","江門(mén)","湛江","茂名","肇慶","惠州","梅州","汕尾","陽(yáng)江","河源","中山","揭陽(yáng)","云浮"],["南寧","柳州","桂林","梧州","北海","防城港","欽州","貴港","玉林","百色","賀州","河池","來(lái)賓","崇左"],["???,"三亞"],["成都","自貢","攀枝花","瀘州","德陽(yáng)","綿陽(yáng)","廣元","遂寧","內(nèi)江","樂(lè)山","南充","宜賓","廣安","達(dá)州","眉山","雅安","巴中","資陽(yáng)","阿壩","甘孜","涼山"],["貴陽(yáng)","六盤(pán)水","遵義","安順","銅仁","畢節(jié)","黔西南","黔東南","黔南"],["昆明","曲靖","玉溪","保山","昭通","麗江","普洱","臨滄","文山","紅河","西雙版納","楚雄","大理","德宏","怒江","迪慶"],["拉薩","昌都","山南","日喀則","那曲","阿里","林芝"],["西安","銅川","寶雞","咸陽(yáng)","渭南","延安","漢中","榆林","安康","商洛"],["蘭州","白銀","定西","敦煌","嘉峪關(guān)","金昌","天水","武威","張掖","平?jīng)?,"酒泉","慶陽(yáng)","臨夏","隴南","甘南"],["西寧","海東","海北","黃南","海南","果洛","玉樹(shù)","海西"],["銀川","石嘴山","吳忠","固原","中衛(wèi)"],["烏魯木齊","克拉瑪依","吐魯番","哈密","和田","阿克蘇","喀什","克孜勒蘇柯?tīng)柨俗?,"巴音郭楞蒙古","昌吉","博爾塔拉蒙古","伊犁哈薩克","阿勒泰"],["臺(tái)北","高雄","基隆","臺(tái)中","臺(tái)南","新竹","嘉義"]];functiongetCity(){//獲得省份下拉框的對(duì)象varsltProvince=document.forms[0].province;//獲得城市下拉框的對(duì)象varsltCity=document.forms[0].city;//得到對(duì)應(yīng)省份的城市數(shù)組varprovinceCity=city[sltProvince.selectedIndex-1];//清空城市下拉框,僅留提示選項(xiàng)sltCity.length=1;//將城市數(shù)組中的值填充到城市下拉框中for(vari=0;i<provinceCity.length;i++){sltCity[i+1]=newOption(provinceCity[i],provinceCity[i]);}}</script><styletype="text/css"><!--body{ background-image:url();}.style4{font-size:12px}--></style></head><body><formname="form1"method="post"action="js.htm"onSubmit="returncheckForm()"><tablewidth="688"border="0"align="center"><tralign="center"><tdcolspan="3">用戶(hù)注冊(cè)</td></tr><tr><tdwidth="130">用戶(hù)名:</td><tdwidth="343"><inputtype="text"name="textname"id="divname"onBlur="checkna()"><spanclass="style4"></span></td><tdwidth="201"><divid="divname">請(qǐng)輸入6-12位用戶(hù)名</div></td></tr><tr><td>密碼:</td><td><inputtype="password"name="textpassword1"id="textpassword1"onBlur="checkpsd1()"><spanclass="style4"></span></td><td><divid="divpassword1">請(qǐng)輸入密碼,長(zhǎng)度6-12,字母和數(shù)字的組合</div></td></tr><tr><td>再次輸入密碼:</td><td><inputtype="password"name="textpassword2"id="textpassword2"onBlur="checkpsd2()"><spanclass="style4"></span></td><td><divid="divpassword2">請(qǐng)?jiān)俅屋斎朊艽a</div></td></tr><tr><tdheight="23">性別:</td><td><inputname="sex"type="radio"id="sex"onBlur="checksex()"value="1"checked>男<inputtype="radio"name="sex"value="0"id="sex"onBlur="checksex()">女</td><td><divid="divsex"></div></td></tr><tr><td>請(qǐng)選擇興趣愛(ài)好:</td><td><inputname="box"type="checkbox"id="box"value="checkbox">游泳<inputtype="checkbox"name="box"id="box"value="checkbox">電腦<inputtype="checkbox"name="box"id="box"value="checkbox">羽毛球<inputtype="checkbox"name="box"id="box"value="checkbox">籃球<inputtype="checkbox"name="box"id="box"value="checkbox">跑步<inputtype="checkbox"name="box"id="box"value="checkbox"onBlur="checknum()">音樂(lè)</td><td><divid="divbox">請(qǐng)選擇至少兩個(gè)</div></td></tr><tr><td>個(gè)人簡(jiǎn)歷:</td><td><textareaname="textarea"id="textarea"onBlur="checkarea()"></textarea></td><td><divid="divarea">請(qǐng)輸入您的個(gè)人簡(jiǎn)歷</div></td></tr><tr><td>出生日期:</td><scriptlanguage="JavaScript"><!--functionwindow.onload(){strYYYY=document.form1.YYYY.outerHTML;strMM=document.form1.MM.outerHTML;strDD=document.form1.DD.outerHTML;MonHead=[31,28,31,30,31,30,31,31,30,31,30,31];//先給年下拉框賦內(nèi)容vary=newDate().getFullYear();varstr=strYYYY.substring(0,strYYYY.length-9);for(vari=(y-30);i<(y+1);i++)//以今年為準(zhǔn),前30年{str+="<optionvalue='"+i+"'>"+i+"</option>\r\n";}document.form1.YYYY.outerHTML=str+"</select>";//賦月份的下拉框varstr=strMM.substring(0,strMM.length-9);for(vari=1;i<13;i++){str+="<optionvalue='"+i+"'>"+i+"</option>\r\n";}document.form1.MM.outerHTML=str+"</select>";document.form1.YYYY.value=y;document.form1.MM.value=newDate().getMonth()+1;varn=MonHead[newDate().getMonth()];if(newDate().getMonth()==1&&IsPinYear(YYYYvalue))n++;writeDay(n);//賦日期下拉框document.form1.DD.value=newDate().getDate();}functionYYYYMM(str)//年發(fā)生變化時(shí)日期發(fā)生變化(主要是判斷閏平年){varMMvalue=document.form1.MM.options[document.form1.MM.selectedIndex].value;if(MMvalue==""){DD.outerHTML=strDD;return;}varn=MonHead[MMvalue-1];if(MMvalue==2&&IsPinYear(str))n++;writeDay(n)}functionMMDD(str)//月發(fā)生變化時(shí)日期聯(lián)動(dòng){varYYYYvalue=document.form1.YYYY.options[document.form1.YYYY.selectedIndex].value;if(str==""){DD.outerHTML=strDD;return;}varn=MonHead[str-1];if(str==2&&IsPinYear(YYYYvalue))n++;writeDay(n)}functionwriteDay(n)//據(jù)條件寫(xiě)日期的下拉框{vars=strDD.substring(0,strDD.length-9);for(vari=1;i<(n+1);i++)s+="<optionvalue='"+i+"'>"+i+"</option>\r\n";document.form1.DD.outerHTML=s+"</select>";}functionIsPinYear(year)//判斷是否閏平年{return(0==year%4&&(year%100!=0||year%400==0))}//--></script><td><selectname=YYYYonchange="YYYYMM(this.value)"></select><selectname=MMonchange="MMDD(this.value)"></select><selectname=DD></select></td></tr><tr><td>出生地:</td><td><selectname="province"onChange="getCity()"><optionvalue="null"selected="selected">請(qǐng)選擇所在省份</option><optionvalue="直轄市">直轄市</option><optionvalue="河北">河北</option><optionvalue="山西">山西</option><optionvalue="內(nèi)蒙古">內(nèi)蒙古</option><optionvalue="遼寧">遼寧</option><optionvalue="吉林">吉林</option><optionvalue="黑龍江">黑龍江</option><optionvalue="江蘇">江蘇</option><optionvalue="浙江">浙江</option><optionvalue="安徽">安徽</option><optionvalue="福建">福建</option><optionvalue="江西">江西</option><optionvalue="山東">山東</option><optionvalue="河南">河南</option><optionvalue="湖北">湖北</option><optionvalue="湖南">湖南</option><optionvalue="廣東">廣東</option><optionvalue="廣西">廣西</option><optionvalue="海南">海南</option><optionvalue="四川">四川</option><optionvalue="貴州">貴州</option><optionvalue="云南">云南</opti

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論