最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

HTML form表單提交方法案例詳解

 更新時(shí)間:2021年08月19日 16:38:26   作者:菜鳥一縷清風(fēng)  
這篇文章主要介紹了HTML form表單提交方法案例詳解,本篇文章通過簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下

form表單提交方式總結(jié)一下:

一、利用submit按鈕實(shí)現(xiàn)提交,當(dāng)點(diǎn)擊submit按鈕時(shí),觸發(fā)onclick事件,由JavaScript里函數(shù)判斷輸入內(nèi)容是否為空,如果為空,返回false, 不提交,如果不為空,提交到由action指定的地址。

<script type="text/javascript">
         function check(form) {
              if(form.userId.value=='') {
                    alert("請(qǐng)輸入用戶帳號(hào)!");
                    form.userId.focus();
                    return false;
               }
               if(form.password.value==''){
                    alert("請(qǐng)輸入登錄密碼!");
                    form.password.focus();
                    return false;
                 }
                 return true;
         }
</script>
<form action="login.do?act=login" method="post">
    用戶帳號(hào)<input type=text name="userId" size="18" value="" ><br>
    登錄密碼<input type="password" name="password" size="19" value=""/>      
           <input type=submit name="submit1" value="登陸" onclick="return check(this.form)">  
</form>

二、利用button按鈕實(shí)現(xiàn)提交,當(dāng)點(diǎn)擊button按鈕時(shí),觸發(fā)onclick事件,由JavaScript里函數(shù)判斷輸入內(nèi)容是否為空,如果為空,返回false, 不提交,如果不為空,提交到由action指定的地址,由于button按鈕不具備自動(dòng)提交的功能,所以由JavaScript實(shí)現(xiàn)提交。

<script type="text/javascript">
         function check(form) {
              if(form.userId.value=='') {
                    alert("請(qǐng)輸入用戶帳號(hào)!");
                    form.userId.focus();
                    return false;
               }
               if(form.password.value==''){
                    alert("請(qǐng)輸入登錄密碼!");
                    form.password.focus();
                    return false;
                }
                  document.myform.submit();
            }
    </script>
<form action="login.do?act=login" name="myform" method="post">
    用戶帳號(hào)<input type=text name="userId" size="18" value="" ><br>
    登錄密碼<input type="password" name="password" size="19" value=""/>      
    <input type=button name="submit1" value="登陸" onclick="check(this.form)">  
</form>

三、利用submit按鈕實(shí)現(xiàn)提交,當(dāng)點(diǎn)擊submit按鈕時(shí),先觸發(fā)onsubmit事件,由JavaScript里函數(shù)判斷輸入內(nèi)容是否為空,如果為空,返回false, 不提交,如果不為空,提交到由action指定的地址。

<script type="text/javascript">
         function check(form) {
              if(form.userId.value=='') {
                    alert("請(qǐng)輸入用戶帳號(hào)!");
                    form.userId.focus();
                    return false;
               }
               if(form.password.value==''){
                    alert("請(qǐng)輸入登錄密碼!");
                    form.password.focus();
                    return false;
                }
                return true;
         }
</script>
<form action="login.do?act=login" method="post" onsubmit="return check(this)">
    用戶帳號(hào)<input type=text name="userId" size="18" value="" ><br>
    登錄密碼<input type="password" name="password" size="19" value=""/>      
    <input type=submit name="submit1" value="登陸"> 
</form> 

以上就是form表單常用的三種提交方式,有不明白的地方,歡迎qq交流:317856821

到此這篇關(guān)于HTML form表單提交方法案例詳解的文章就介紹到這了,更多相關(guān)HTML form表單提交內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論

凤山市| 永新县| 尚志市| 张家港市| 乌苏市| 天等县| 志丹县| 舒兰市| 阳山县| 琼海市| 奉化市| 留坝县| 驻马店市| 游戏| 锡林浩特市| 大姚县| 南川市| 普宁市| 太和县| 大庆市| 二连浩特市| 三原县| 洛隆县| 大冶市| 额敏县| 四平市| 东兰县| 舟山市| 澜沧| 旺苍县| 泰宁县| 保定市| 陕西省| 宣恩县| 通化县| 栖霞市| 崇礼县| 江源县| 文登市| 和静县| 庆云县|