亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 編程 > JavaScript > 正文

JavaScript 完成注冊頁面表單校驗的實例

2019-11-19 15:44:27
字體:
來源:轉載
供稿:網友

1、步驟分析

第一步:確定事件(onsubmit)并為其綁定一個函數

第二步:書寫這個函數(獲取用戶輸入的數據<獲取數據時需要在指定位置定義一個 id>)

第三步:對用戶輸入的數據進行判斷

第四步:數據合法(讓表單提交)

第五步:數據非法(給出錯誤提示信息,不讓表單提交)

問題:如何控制表單提交?

關于事件 onsubmit:一般用于表單提交的位置,那么需要在定義函數的時候給出一個 返回值。

onsubmit = return checkForm()

2、完成注冊頁面表單校驗

<!DOCTYPE html><html> <head>  <meta charset="UTF-8">  <title>注冊頁面</title>  <script>   function checkForm(){    //alert("aa");        /**校驗用戶名*/    //1.獲取用戶輸入的數據    var uValue=document.getElementById("user").value;    //alert(uValue);    if(uValue==""){     //2.給出錯誤提示信息     alert("用戶名不能為空");     return false;    }        /**校驗密碼*/    var pValue=document.getElementById("password").value;    if(pValue==""){     //注意空的表示方法     alert("密碼不能為空");     return false;    }         /** 校驗確認密碼*/    var rpValue=document.getElementById("repassword").value;    if(rpValue!=pValue){     alert("兩次密碼輸入不一致!");     return false;    }        /**校驗郵箱*/    var eValue=document.getElementById("email").value;    if(!/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/.test(eValue)){     alert("郵箱格式不正確!");    }   }  </script> </head> <body>  <table border="1px" align="center" width="1300px" cellpadding="0px" cellspacing="0px">      <!--1.logo部分-->   <tr>    <td>     <!--嵌套一個一行三列的表格-->     <table border="1px" width="100%">      <tr height="50px">       <td width="33.3%">        <img src="../img/logo2.png" height="47px" />       </td>       <td width="33.3%">        <img src="../img/header.png" height="47px"/>       </td>       <td width="33.3%">        <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >登錄</a>        <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >注冊</a>        <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >購物車</a>       </td>      </tr>     </table>    </td>   </tr>      <!--2.導航欄部分-->   <tr height="50px" >    <td bgcolor="black">     <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><font size="3" color="white">首頁</font></a>                <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><font color="white">手機數碼</font></a>             <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><font color="white">電腦辦公</font></a>            <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><font color="white">鞋靴箱包</font></a>            <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><font color="white">家用電器</font></a>    </td>   </tr>      <!--3.注冊表單-->   <tr>    <td height="600px" background="../img/regist_bg.jpg">     <!--嵌套一個十行二列的表格-->     <form action="#" method="get" name="regForm" onsubmit="return checkForm()">     <table border="1px" width="750px" height="400px" align="center" cellpadding="0px" cellspacing="0px" bgcolor="white">      <tr height="40px">       <td colspan="2">        <font size="4">會員注冊</font>   USER REGISTER       </td>      </tr>      <tr>       <td>用戶名</td>       <td>        <input type="text" name="user" size="35px" id="user"/>       </td>      </tr>      <tr>       <td>密碼</td>       <td>        <input type="password" name="password" size="35px" id="password"/>       </td>      </tr>      <tr>       <td>確認密碼</td>       <td>        <input type="password" name="repassword" size="35px" id="repassword"/>       </td>      </tr>      <tr>       <td>E-mail</td>       <td>        <input type="text" name="e-mail" size="35px" id="email"/>       </td>      </tr>      <tr>       <td>姓名</td>       <td>        <input type="text" name="username" size="35px"/>       </td>      </tr>      <tr>       <td>性別</td>       <td>        <input type="radio" name="sex" value="男"/>男        <input type="radio" name="sex" value="女"/>女       </td>      </tr>      <tr>       <td>出生日期</td>       <td>        <input type="text" name="birthday" size="35px"/>       </td>      </tr>      <tr>       <td>驗證碼</td>       <td>        <input type="text" name="yzm" />        <img src="../img/yanzhengma.png" />       </td>      </tr>      <tr align="center">       <td colspan="2">        <input type="submit" value="注冊" />       </td>      </tr>     </table>     </form>    </td>   </tr>      <!--4.廣告圖片-->   <tr>    <td>     <img src="../img/footer.jpg" width="100%"/>    </td>   </tr>      <!--5.友情鏈接和版權信息-->   <tr>    <td align="center">     <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><font>關于我們</font></a>     <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><font>聯系我們</font></a>     <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><font>招賢納士</font></a>     <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><font>法律聲明</font></a>     <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><font>友情鏈接</font></a>     <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><font>支付方式</font></a>     <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><font>配送方式</font></a>     <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><font>服務聲明</font></a>     <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><font>廣告聲明</font></a>     <p>      Copyright © 2005-2016 hh商城 版權所有      </p>    </td>   </tr>  </table> </body></html>

在校驗確認密碼這部分使用了正則表達式(不需要記憶,需要時查找文檔)

正則式.test(校驗對象)為真表示符合條件,為假則不符合。

以上這篇JavaScript 完成注冊頁面表單校驗的實例就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
久久全球大尺度高清视频| 国产精品扒开腿做爽爽爽视频| 久久精品国产69国产精品亚洲| 亚洲欧美中文字幕| 日韩av网站导航| 国产精品日韩在线播放| 中文字幕少妇一区二区三区| 久久久精品久久久久| 亚洲级视频在线观看免费1级| 亚洲人在线视频| 国产69精品久久久久9| 亚洲激情在线视频| 亚洲第一区第一页| 米奇精品一区二区三区在线观看| 国产精品久久久久不卡| 欧美日韩精品在线播放| 亚洲美女黄色片| 亚洲色图欧美制服丝袜另类第一页| 日韩成人久久久| 欧美国产激情18| 麻豆一区二区在线观看| 亚洲精品久久久久久久久久久久久| 欧美国产精品日韩| 久久99久久久久久久噜噜| 亚洲精品久久久久中文字幕欢迎你| 欧美日韩亚洲一区二区| 国产精品电影观看| 久久91亚洲精品中文字幕奶水| 国产欧美在线视频| 最新国产成人av网站网址麻豆| 亚洲一区美女视频在线观看免费| 日韩欧美在线网址| 国产一区二区丝袜高跟鞋图片| 色老头一区二区三区| 日韩精品视频中文在线观看| 亚洲精品乱码久久久久久金桔影视| 九九热r在线视频精品| 91夜夜揉人人捏人人添红杏| 中文字幕日韩在线视频| 久久久国产精品亚洲一区| 伊人伊成久久人综合网站| 久久精品夜夜夜夜夜久久| 黑人巨大精品欧美一区二区免费| 岛国av一区二区| 人九九综合九九宗合| 美女精品久久久| 成人免费淫片aa视频免费| 亚洲综合日韩中文字幕v在线| 国产伊人精品在线| 8050国产精品久久久久久| 日韩av一区二区在线观看| 55夜色66夜色国产精品视频| 96国产粉嫩美女| 国产精品美女在线| 日韩精品有码在线观看| 美日韩精品免费视频| 亚洲欧美日韩天堂一区二区| 日韩视频免费大全中文字幕| 懂色aⅴ精品一区二区三区蜜月| 欧美疯狂性受xxxxx另类| 日韩精品久久久久久久玫瑰园| 1769国内精品视频在线播放| 中文字幕精品av| 日韩福利视频在线观看| 欧美洲成人男女午夜视频| 成人黄色免费网站在线观看| 精品偷拍各种wc美女嘘嘘| 欧美成人精品在线播放| 欧美专区国产专区| 欧美最猛性xxxx| 久久久极品av| 久久久久久网址| 色先锋资源久久综合5566| 亚洲日本aⅴ片在线观看香蕉| 久久天天躁日日躁| 久久久久久久av| 成人黄色网免费| xxxxxxxxx欧美| 久久精品国产亚洲精品| 欧美午夜片在线免费观看| 欧美成人在线影院| 高潮白浆女日韩av免费看| 国产精品a久久久久久| 夜夜狂射影院欧美极品| 中文字幕不卡在线视频极品| 久久人体大胆视频| 久久久中精品2020中文| 91手机视频在线观看| 国产精品久久久久久久久借妻| 欧美午夜精品久久久久久人妖| 亚洲老头同性xxxxx| 久久天天躁夜夜躁狠狠躁2022| 国产亚洲a∨片在线观看| 久久久久久久网站| 激情亚洲一区二区三区四区| 日韩在线视频免费观看| 亚洲а∨天堂久久精品喷水| 国产精品第一页在线| 日韩精品高清视频| 欧美精品亚州精品| 国产精品十八以下禁看| 在线成人激情黄色| 亚洲福利在线看| xxxx性欧美| 久久国产加勒比精品无码| 亚洲精品欧美极品| 日本久久久久久久久久久| 91成人在线视频| 国产激情视频一区| 国产精品视频资源| 91免费欧美精品| 日韩中文第一页| 亚洲精品视频播放| 色爱精品视频一区| 伊人久久精品视频| 亚洲新声在线观看| 国产精品视频白浆免费视频| 欧美精品情趣视频| 亚洲奶大毛多的老太婆| 国产精品美腿一区在线看| 日韩欧美在线视频| 国产成人精品日本亚洲专区61| 日韩av一区二区在线| 日韩av在线不卡| 日韩精品一区二区视频| 色综合久久88色综合天天看泰| 欧美激情伊人电影| 亚洲第一免费网站| 欧美精品第一页在线播放| 日韩精品免费电影| 一区二区三区www| 国产精品久久久久久久美男| 国产精品久久久久久久久久ktv| 亚洲美女av电影| 欧美视频不卡中文| 亚洲男子天堂网| 欧美在线视频一二三| 97精品国产97久久久久久免费| 一区二区国产精品视频| 亚洲欧美一区二区精品久久久| 国产主播精品在线| 另类专区欧美制服同性| 91产国在线观看动作片喷水| 国产日本欧美一区二区三区| 8x海外华人永久免费日韩内陆视频| 秋霞成人午夜鲁丝一区二区三区| 成人中文字幕+乱码+中文字幕| 欧美黑人又粗大| 国产啪精品视频| 成人在线播放av| 欧美精品午夜视频| 久久九九免费视频| 国产欧美一区二区三区久久人妖| 国产视频亚洲视频| 92看片淫黄大片看国产片| 欧美黑人狂野猛交老妇| 久久精品国产电影| 久久人人爽亚洲精品天堂| 日韩欧美在线免费| 精品成人乱色一区二区| 孩xxxx性bbbb欧美| 青草热久免费精品视频| 成人国产精品色哟哟| 亚洲精品日韩在线|