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

W3C Tutorial (8): W3C XML Schema Activities

XML Schema is an XML-based alternative to DTD. XM...

Vue.js uses Element-ui to implement the navigation menu

This article shares the specific code for impleme...

Implementation of mounting NFS shared directory in Docker container

Previously, https://www.jb51.net/article/205922.h...

Detailed explanation of MySQL data rows and row overflow mechanism

1. What are the formats of lines? You can see you...

How much do you know about JavaScript inheritance?

Table of contents Preface The relationship betwee...

Vue3 encapsulates the side navigation text skeleton effect component

Vue3 project encapsulation side navigation text s...

Vue project implements left swipe delete function (complete code)

Achieve results The code is as follows html <t...

Each time Docker starts a container, the IP and hosts specified operations

Preface Every time you use Docker to start a Hado...

HTML+CSS to create a top navigation bar menu

Navigation bar creation: Technical requirements: ...

Analysis of the principles of docker containers

Table of contents 01 What is the essence of a con...

HTML Tutorial: Collection of commonly used HTML tags (5)

Related articles: Beginners learn some HTML tags ...