Example of Form action and onSubmit

Example of Form action and onSubmit
First: action is an attribute of form. HTML5 has defined it as a required attribute value. onSubmit is an event, and a function verification is performed when submitting through <input type="submit" />. .

Second: As for the order of execution, my personal understanding is that onSubmit comes first, then verification. When the verification returns false, the action="url" address cannot be reached. If it returns true or no return value is given, it passes and redirects to the URL address.

Copy code
The code is as follows:

function check(){
var oText = document.getElementById("in").value;
alert(oText);
if(oText == "false"){
return false;
}
else {
return true;}
}</span>


Copy code
The code is as follows:

<span style="font-size:14px"> <form action="table1.html" onSubmit="return check();">
<div><input type="text" id="in" /><input type="submit" value="Submit" /></div>
</form></span>

onSubmit="return Fun();" The return here must be written, shouldn't it be written? You can try not to write! ! !

In short: onSubmit is for verification, and action is the link address after the jump.

<<:  JavaScript function detailed introduction

>>:  How to build ssh service based on golang image in docker

Recommend

How to build a MySQL high-availability and high-performance cluster

Table of contents What is MySQL NDB Cluster Preli...

Centos7 installation of Nginx integrated Lua sample code

Preface The computer I use is a Mac, and the oper...

Docker compose custom network to achieve fixed container IP address

Due to the default bridge network, the IP address...

Reasons and methods for Waiting for table metadata lock in MySQL

When MySQL performs DDL operations such as alter ...

Linux completely removes node.js and reinstalls it through the yum command

first step Delete it once with the built-in packa...

Tips for implementing multiple borders in CSS

1. Multiple borders[1] Background: box-shadow, ou...

Solution to data duplication when using limit+order by in MySql paging

Table of contents summary Problem Description Ana...

Implementation steps for building multi-page programs using Webpack

It is very common to use webpack to build single-...

HTML form value transfer example through get method

The google.html interface is as shown in the figur...

Explanation of the execution priority of mySQL keywords

As shown below: from table where condition group ...

JavaScript timer to achieve seamless scrolling of pictures

This article shares the specific code of JavaScri...

Use Rem layout to achieve adaptive

I have written an article about mobile adaptation...

Detailed steps for installing Tomcat, MySQL and Redis with Docker

Table of contents Install Tomcat with Docker Use ...