<form id="hz9zz"></form>
  • <form id="hz9zz"></form>

      <nobr id="hz9zz"></nobr>

      <form id="hz9zz"></form>

    1. 明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

      html中對于form表單submit與button的提交用法詳細說明

      [摘要]1.當輸入用戶名和密碼為空的時候,需要判斷。這時候就用到了校驗用戶名和密碼,這個需要在jsp的前端頁面寫;有兩種方法,一種是用submit提交。一種是用button提交。方法一:在jsp的前端頁面的頭部插入一個js方法:function checkUser(){var result = docum...
      1.當輸入用戶名和密碼為空的時候,需要判斷。這時候就用到了校驗用戶名和密碼,這個需要在jsp的前端頁面寫;有兩種方法,一種是用submit提交。一種是用button提交。
      方法一:
      在jsp的前端頁面的頭部插入一個js方法:

      function checkUser(){
         var result = document.getElementById("userid").value;
         var password = document.getElementById("userpassid").value;
         if(result == ""  ){
           alert("用戶名不能為空");
           return false;
         }
         if(password == ""  ){
          alert("密碼不能為空");
           return false;
         }else{
         return true;
         }
      }

      在form表單里寫成這樣:

      <form id="formid"  name= "myform" method = 'post'  action = 'user_login_submit.action'
      onsubmit = "return checkUser();
      " >
                  <table width="100%" border="0">
                    <tr>
                      <td width="60" height="40" align="right">用戶名&nbsp;</td>
                      <td><input type="text" value="" class="text2" name = "username" id = "userid"/></td>
                    </tr>
                    <tr>
                      <td width="60" height="40" align="right">密&nbsp;&nbsp;碼&nbsp;</td>
                      <td><input type="password" value="" class="text2" name = "userpass" id = "userpassid"/></td>
                    </tr>
                    <tr>
                      <td width="60" height="40" align="right">&nbsp;</td>
                      <td><p class="c4">
                          <input type="submit" value="" class="btn2"  />

      方法二:

      function checkUser(){
         var result = document.getElementById("userid").value;
         var password = document.getElementById("passid").value;
         if(result == ""  ){
           alert("用戶名不能為空");
           return false;
         }
         if(password == ""  ){
          alert("密碼不能為空");
           return false;
         }
        document.getElementById("formid").submit();
      }

      form表格的寫法,需要寫id

      <form id="formid" method = 'post'  action = 'user_login_submit.action'  >

      button按鈕的寫法如下:

      <input type="button" value="" class="btn2" onclick = "checkUser();" />

      以上就是html中關于form表單submit和button的提交用法詳解的詳細內容,更多請關注php中文網其它相關文章!


      網站建設是一個廣義的術語,涵蓋了許多不同的技能和學科中所使用的生產和維護的網站。




      日韩精品一区二区三区高清