Home > Web Front-end > Bootstrap Tutorial > How to submit information in bootstrap form

How to submit information in bootstrap form

Release: 2019-07-27 11:27:59
Original
11193 people have browsed it

How to submit information in bootstrap form

When the entered username and password are empty, judgment is required. At this time, verification of username and password is used. This needs to be written on the front-end page of jsp; There are two methods, one is to submit using submit. One is to submit using button.

Method 1:

Insert a js method at the head of the jsp front-end page:

 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;
   }
}
Copy after login

Write it like this in the form:

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

Method 2:

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();
}
Copy after login

To write the form, you need to write the id

<form id="formid" method = &#39;post&#39;  action = &#39;user_login_submit.action&#39;  >
Copy after login

The button is written as follows:

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

Recommendation: bootstrap introductory tutorial

The above is the detailed content of How to submit information in bootstrap form. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template