Home
Web Front-end
JS Tutorial
Solution to the problem that the submit event of the Form Form does not respond_Form special effects



Solution to the problem that the submit event of the Form Form does not respond_Form special effects
May 16, 2016 pm 06:59 PM
submit
Not responding
event
1. Problem description
By analogy, I used input.select() to test, but it was able to respond to the select event. Putting this reason aside for now, let’s see how to solve the current problem first.
Code example that does not respond to events:
[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute]
In actual operation, there will be no alert comes out.
Although using the submit method to submit a form goes against the principles of Unobtrustive Javascript, it is sometimes necessary. For example, when making a search prompt (auto-complete) and selecting an Item, you need to use JS to submit the search form. 2. Problem Analysis
Since it does not respond to events, these events can only be triggered manually. Before determining the manual triggering plan, review the event registration method:
"Original" There are two ways to register, see the code example: If you need to introduce external Js, you need to refresh it to execute
]
Such a registration event will Added a method onsubmit to the form. Therefore, you can directly execute this method, which is equivalent to manually triggering the event. [Ctrl A Select All Note:
If you need to introduce external Js, you need to refresh to execute
]
This way you can get an alert.
But today’s “advanced” DOM2 standard registration method and IE’s registration method attachEvent are already very commonly used. For these registration methods, the onsubmit method does not exist. If you use form.onsubmit(), an error will be reported directly.
3. Solution
[Ctrl A Select all Note:
If you need to introduce external Js, you need to refresh to execute
]
By analogy, I used input.select() to test, but it was able to respond to the select event. Putting this reason aside for now, let’s see how to solve the current problem first.
Code example that does not respond to events:
[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute
In actual operation, there will be no alert comes out.
Although using the submit method to submit a form goes against the principles of Unobtrustive Javascript, it is sometimes necessary. For example, when making a search prompt (auto-complete) and selecting an Item, you need to use JS to submit the search form. 2. Problem Analysis
Since it does not respond to events, these events can only be triggered manually. Before determining the manual triggering plan, review the event registration method:
"Original" There are two ways to register, see the code example: If you need to introduce external Js, you need to refresh it to execute
]
Such a registration event will Added a method onsubmit to the form. Therefore, you can directly execute this method, which is equivalent to manually triggering the event. [Ctrl A Select All Note:
If you need to introduce external Js, you need to refresh to execute
]
This way you can get an alert.
But today’s “advanced” DOM2 standard registration method and IE’s registration method attachEvent are already very commonly used. For these registration methods, the onsubmit method does not exist. If you use form.onsubmit(), an error will be reported directly.
3. Solution
[Ctrl A Select all Note:
If you need to introduce external Js, you need to refresh to execute
]
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Get upcoming calendar events on your iPhone lock screen

In JavaScript, what is the purpose of the 'oninput' event?

How to implement calendar functions and event reminders in PHP projects?

How to implement change event binding of select elements in jQuery

Detailed explanation of input box binding events in Vue documents

What are the commonly used events in jquery

A Deep Dive into Close Button Events in jQuery
