<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當(dāng)前位置: 首頁 - 科技 - 知識百科 - 正文

        JavaScript實現(xiàn)注冊頁面表單校驗的實例分享

        來源:懂視網(wǎng) 責(zé)編:小OO 時間:2020-11-27 20:14:13
        文檔

        JavaScript實現(xiàn)注冊頁面表單校驗的實例分享

        1、步驟分析;第一步:確定事件(onsubmit)并為其綁定一個函數(shù)。第二步:書寫這個函數(shù)(獲取用戶輸入的數(shù)據(jù)<;獲取數(shù)據(jù)時需要在指定位置定義一個 id>;)。第三步:對用戶輸入的數(shù)據(jù)進行判斷。第四步:數(shù)據(jù)合法(讓表單提交)。第五步:數(shù)據(jù)非法(給出錯誤提示信息,不讓表單提交)。問題:如何控制表單提交。關(guān)于事件 onsubmit:一般用于表單提交的位置,那么需要在定義函數(shù)的時候給出一個 返回值。onsubmit = return checkForm()。2、完成注冊頁面表單校驗。
        推薦度:
        導(dǎo)讀1、步驟分析;第一步:確定事件(onsubmit)并為其綁定一個函數(shù)。第二步:書寫這個函數(shù)(獲取用戶輸入的數(shù)據(jù)<;獲取數(shù)據(jù)時需要在指定位置定義一個 id>;)。第三步:對用戶輸入的數(shù)據(jù)進行判斷。第四步:數(shù)據(jù)合法(讓表單提交)。第五步:數(shù)據(jù)非法(給出錯誤提示信息,不讓表單提交)。問題:如何控制表單提交。關(guān)于事件 onsubmit:一般用于表單提交的位置,那么需要在定義函數(shù)的時候給出一個 返回值。onsubmit = return checkForm()。2、完成注冊頁面表單校驗。

        下面小編就為大家?guī)硪黄狫avaScript 完成注冊頁面表單校驗的實例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

        1、步驟分析

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

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

        第三步:對用戶輸入的數(shù)據(jù)進行判斷

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

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

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

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

        onsubmit = return checkForm()

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

        <!DOCTYPE html>
        <html>
         <head>
         <meta charset="UTF-8">
         <title>注冊頁面</title>
         <script>
         function checkForm(){
         //alert("aa");
         
         /**校驗用戶名*/
         //1.獲取用戶輸入的數(shù)據(jù)
         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.導(dǎo)航欄部分-->
         <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">手機數(shù)碼</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.友情鏈接和版權(quán)信息-->
         <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>關(guān)于我們</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>聯(lián)系我們</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>服務(wù)聲明</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商城 版權(quán)所有 
         </p>
         </td>
         </tr>
         </table>
         </body>
        </html>

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

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

        聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        JavaScript實現(xiàn)注冊頁面表單校驗的實例分享

        1、步驟分析;第一步:確定事件(onsubmit)并為其綁定一個函數(shù)。第二步:書寫這個函數(shù)(獲取用戶輸入的數(shù)據(jù)<;獲取數(shù)據(jù)時需要在指定位置定義一個 id>;)。第三步:對用戶輸入的數(shù)據(jù)進行判斷。第四步:數(shù)據(jù)合法(讓表單提交)。第五步:數(shù)據(jù)非法(給出錯誤提示信息,不讓表單提交)。問題:如何控制表單提交。關(guān)于事件 onsubmit:一般用于表單提交的位置,那么需要在定義函數(shù)的時候給出一個 返回值。onsubmit = return checkForm()。2、完成注冊頁面表單校驗。
        推薦度:
        標簽: 注冊 分享 頁面
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: CAOPORN国产精品免费视频| 亚洲国产成人无码AV在线影院| 精品亚洲一区二区三区在线观看 | 亚洲资源在线观看| 亚洲伦另类中文字幕| 伊人久久五月丁香综合中文亚洲| 亚洲AV无码一区二区乱子仑| 国产成人高清精品免费观看| 中文字幕免费在线看线人| 免费观看的毛片手机视频| 亚洲精品国偷自产在线| 亚洲一区欧洲一区| 91视频免费观看| 丁香花免费完整高清观看| 亚洲一本大道无码av天堂| 2020亚洲男人天堂精品| 性感美女视频免费网站午夜 | 日韩精品成人无码专区免费| 久久精品国产69国产精品亚洲| 日本亚洲色大成网站www久久 | 亚洲AV日韩AV鸥美在线观看| 男人和女人高潮免费网站| www.免费在线观看| 亚洲精品无码一区二区| 久草免费在线观看视频| 亚洲国产AV无码专区亚洲AV | 免费无码一区二区三区| 亚洲精品美女久久久久99小说| 亚洲大成色www永久网址| 免费一级毛片正在播放| 亚洲 欧洲 日韩 综合在线| 国产精品二区三区免费播放心 | 在线观看亚洲免费| va天堂va亚洲va影视中文字幕| 波多野结衣久久高清免费| 9久热这里只有精品免费| 亚洲午夜久久久精品电影院| 99精品视频在线视频免费观看| 亚洲中文字幕AV每天更新| 亚洲日韩国产成网在线观看| 最近免费中文字幕大全免费版视频|