Introduction to the use of form OnSubmit and input type=image

Introduction to the use of form OnSubmit and input type=image
If there is an <input type="image"> here, then pressing this image directly will submit the form.

If there is OnSubmit, this function will be executed first. If it returns false, the form will not be submitted!

Copy code
The code is as follows:

<span style="font-size:14px;"><script language=javascript>
function test()
{
alert("Test!")
}
</script>
<form name="F1" onSubmit="fuck();">
<input type="image" src="" width="51" height="20">
</form></span>

Another example:

Copy code
The code is as follows:

<html>
</head>
<script language="javascript">
function checkEmpty(form){
for(i=0;i<form.length;i++){
alert(form.elements[i].value);
if( form.elements[i].value=="" ){
alert("Form information cannot be empty");
return false;
}
}
}
</script>
<body>
<form name="form" method="post" onSubmit="return checkEmpty(form)">
<input name="name" type="text" size="17">
<input name="password" type="password" size="17">
<input type="image" src="" width="51" height="20">
<input type="button" value="AAA" />
</form>
</body>
<html>

<<:  Summary of pitfalls of using nginx as a reverse proxy for grpc

>>:  Several methods of implementing two fixed columns and one adaptive column in CSS

Recommend

MySQL 8.0.17 installation and configuration graphic tutorial

This article records the graphic tutorial of MySQ...

Implementation of whack-a-mole game in JavaScript

This article shares the specific code for JavaScr...

A summary of some of the places where I spent time on TypeScript

Record some of the places where you spent time on...

HTML n ways to achieve alternate color code sample code

This article mainly introduces the sample code of...

MySQL data type optimization principles

MySQL supports many data types, and choosing the ...

Clean XHTML syntax

Writing XHTML demands a clean HTML syntax. Writing...

JavaScript lazy loading detailed explanation

Table of contents Lazy Loading CSS styles: HTML p...

How to add a disk in Vmware: Expand the disk

This article describes how to add or expand a dis...

A complete guide to CSS style attributes css() and width() in jQuery

Table of contents 1. Basic use of css(): 1.1 Get ...

How to use Linux locate command

01. Command Overview The locate command is actual...

CSS mimics remote control buttons

Note: This demo is tested in the mini program env...

JavaScript canvas to achieve code rain effect

This article shares the specific code for canvas ...

What is a MySQL tablespace?

The topic I want to share with you today is: &quo...