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

Practical example of nested routes in vue.js Router

Table of contents Preface Setting up with Vue CLI...

Teach you how to implement Vue3 Reactivity

Table of contents Preface start A little thought ...

Several ways to submit HTML forms_PowerNode Java Academy

Method 1: Submit via the submit button <!DOCTY...

Building FastDFS file system in Docker (multi-image tutorial)

Table of contents About FastDFS 1. Search for ima...

JavaScript basics for loop and array

Table of contents Loop - for Basic use of for loo...

Implementing a simple Gobang game with native JavaScript

This article shares the specific code for impleme...

Completely uninstall mysql. Personal test!

Cleanly uninstall MySQL. Personally tested, this ...

The difference between br and br/ in HTML

answer from stackflow: Simply <br> is suffic...

How to use ss command instead of netstat in Linux operation and maintenance

Preface When operating and managing Linux servers...

Summary of various implementation methods of mysql database backup

This article describes various ways to implement ...

How to run .sh files in Linux system

There are two ways to run .sh files in Linux syst...

Detailed explanation of CocosCreator message distribution mechanism

Overview This article begins to introduce content...