Home > Web Front-end > JS Tutorial > About using JavaScript to intercept form's submit method implementation

About using JavaScript to intercept form's submit method implementation

高洛峰
Release: 2016-11-26 14:06:55
Original
2414 people have browsed it

About using JavaScript to intercept the submit method of the form

Posted on 2006-12-23 10:37 winder

Recently, I encountered the need to use JS script to uniformly intercept the submit method of the form in the page to modify the request when the page is implicitly submitted. The URL is simply implemented as follows:
Var OldSubmit;
var Form = Document.Forms [0];
If (Form! = NULLLLLL! = 'Undefined') {
// Form.oldsubmi t = FORM. submit; /// cover the submit function to achieve intercepting
Form.submit = function () {
// The operation before submit ..
// Drop the original function to submit
form.oldsubmit ();
}}}}
The above code will be intercepted when it is executed first when the page is loaded. For submissions that are displayed using the submit button, you can monitor the onsubmit event to achieve this. There are many methods for this and there is no big problem.

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template