To summarize the form submission method: 1. Use the submit button to submit. When you click the submit button, the onclick event is triggered. The function in JavaScript determines whether the input content is empty. If it is empty, it returns false and does not submit. If it is not empty, it submits to the address specified by action. <script type="text/javascript"> function check(form) { if(form.userId.value=='') { alert("Please enter your user account!"); form.userId.focus(); return false; } if(form.password.value==''){ alert("Please enter your login password!"); form.password.focus(); return false; } return true; } </script> <form action="login.do?act=login" method="post"> User Account<input type=text name="userId" size="18" value="" ><br> Login password<input type="password" name="password" size="19" value=""/> <input type=submit name="submit1" value="Login" onclick="return check(this.form)"> </form> 2. Use a button to submit. When you click the button, the onclick event is triggered. The function in JavaScript determines whether the input content is empty. If it is empty, it returns false and does not submit. If it is not empty, it submits to the address specified by the action. Since the button does not have the function of automatic submission, submission is implemented by JavaScript. <script type="text/javascript"> function check(form) { if(form.userId.value=='') { alert("Please enter your user account!"); form.userId.focus(); return false; } if(form.password.value==''){ alert("Please enter your login password!"); form.password.focus(); return false; } document.myform.submit(); } </script> <form action="login.do?act=login" name="myform" method="post"> User Account<input type=text name="userId" size="18" value="" ><br> Login password<input type="password" name="password" size="19" value=""/> <input type=button name="submit1" value="Login" onclick="check(this.form)"> </form> 3. Use the submit button to implement submission. When the submit button is clicked, the onsubmit event is triggered first. The function in JavaScript determines whether the input content is empty. If it is empty, it returns false and does not submit. If it is not empty, it submits to the address specified by action. <script type="text/javascript"> function check(form) { if(form.userId.value=='') { alert("Please enter your user account!"); form.userId.focus(); return false; } if(form.password.value==''){ alert("Please enter your login password!"); form.password.focus(); return false; } return true; } </script> <form action="login.do?act=login" method="post" onsubmit="return check(this)"> User Account<input type=text name="userId" size="18" value="" ><br> Login password<input type="password" name="password" size="19" value=""/> <input type=submit name="submit1" value="Login"> </form> The above are the three common ways to submit forms. If you have any questions, please feel free to contact me on QQ: 317856821 This is the end of this article about the detailed case study of HTML form submission method. For more relevant HTML form submission content, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Analysis of MySQL cumulative aggregation principle and usage examples
Table of contents 1. Introduction to NFS-Ganesha ...
In Linux system, both chmod and chown commands ca...
sshd SSH is the abbreviation of Secure Shell, whi...
We know that when using HTML on NetEase Blog, we ...
For example, if your current path is /var/log and...
DML operations refer to operations on table recor...
Table of contents linux 1. What is SWAP 2. What d...
The cursor size in the input box is inconsistent T...
Recently, I plan to deploy a cloud disk on my hom...
Preface Due to the weak typing of JS, loose writi...
Virtual machines are very convenient testing soft...
Preface In the previous interview process, when a...
Table of contents Preface design accomplish summa...
Table of contents Standard execution process opti...
Table of contents 1. What is a prototype? 1.1 Fun...