Home > Web Front-end > JS Tutorial > Some basic usage and techniques of forms_Form special effects

Some basic usage and techniques of forms_Form special effects

WBOY
Release: 2016-05-16 19:28:15
Original
1038 people have browsed it

1. Use images instead of submit buttons
When there is only one submit button, it can be easily implemented without adding an event function. The code is:

Except for changing the label to input type="image", other attributes are the same as those of the label It's the same.

2. Replace all form buttons with images:
The image code format to replace the submit button is

The code image format that replaces the reset button is
 
Note: The formName here is the name attribute value of the form.

3. Form submission verification:
<script><br> function CheckDate(){<br> //Get the input data <br> userName = document.RedForm.userName.value;<br> userEmail = document.RedForm.userEmail.value;<br> //If no name is entered<br>if (userName=="") {<br>alert("Please enter your name");<br>document.RedForm. userName.focus();<br> return false;<br>}else{<br> //If no email is entered, or the email address is wrong (does not contain @)<br>if ((userEmail=="")| |(userEmail.indexOf("@")==-1)) {alert("Please re-enter your email address");<br>document.RedForm.userEmail.focus();<br>return false;<br> }else return true;<br>}<br>}<br> </script>

4. Use any element to submit the form:
Submit the form through onClick="document.form.submit();"; use onClick="document.form.reset();" to reset the form, this way Now, any element can implement form submission.

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