SoFunction
Updated on 2025-02-28

Some basic usage and techniques of forms

1. Use an image instead of the submit button
When there is only one submit button, it can be simply implemented without adding an event function. The code is:
 <input type="image" name="..." src="url" width="" height="..." border="...">
Except for the tag being changed to input type="image", other attributes are the same as those of the <img> tag.

2. Use pictures to replace all form buttons:
The image code format instead of the submit button is
 <input type="image" name="..." src="..." onClick="()">
The code picture format of the reset button is
 <input type="image" name="..." src="..." onClick="()">
Note: The formName here is the name attribute value of the form.

3. Form submission verification:
 <script>
 function CheckDate(){
//Acquiring the input data
 userName = ;
 userEmail = ;
//If you do not enter a name
 if (userName=="") {
alert("Please enter your name");
 ();
 return false;
 }else{
//If the email is not entered, or the email address is incorrect (excluding @)
if ((userEmail=="")||(("@")==-1)) {alert("Please re-enter the email address");
 ();
 return false;
 }else return true;
 }
 }
 </script>

4. Submit the form with any element:
Submit the form through onClick="();"; use onClick="();" to reset the form, so that any element can submit the form.