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

A few things about favicon.ico (it’s best to put it in the root directory)

Open any web page: for example, http://www.baidu....

80 lines of code to write a Webpack plugin and publish it to npm

1. Introduction I have been studying the principl...

How to solve the problem that MySQL cannot start because it cannot create PID

Problem Description The MySQL startup error messa...

A general method for implementing infinite text carousel with native CSS

Text carousels are very common in our daily life....

Summary of commonly used time, date and conversion functions in Mysql

This article mainly summarizes some commonly used...

Vue custom table column implementation process record

Table of contents Preface Rendering setTable comp...

JavaScript canvas implements moving the ball following the mouse

This article example shares the specific code of ...

Solution to MySQL Installer is running in Community mode

Today I found this prompt when I was running and ...

Ten useful and simple MySQL functions

function 0. Display current time Command: select ...

JavaScript Canvas implements Tic-Tac-Toe game

This article shares the specific code of JavaScri...