Form submission problems

Source: Internet
Author: User
HTML Dom Button Object

The button object represents a button in the HTML document.

This element has no default behavior, but must have an onclick event handle for use.

Each time a <input type = "button"> tag appears in an HTML document, a button object is created.

You can access a button by traversing the elements [] array of the form, or by using document. getelementbyid ().

Definition and usage

The click () method simulates a mouse click on the button.

Syntax
Buttonobject. Click ()

Source: http://www.w3school.com.cn/jsref/dom_obj_button.asp
HTML Dom submit object

The submit object represents a submit button in the HTML form ).

Each time a <input type = "Submit"> tag appears in an HTML form, a submit object is created.

Before the form is submitted, the onclick event handle is triggered, and a handle can cancel the form submission by returning fasle.

See the form. Submit () method and form. onsubmit event handle.

Example: Form Verification

You can access a submit button by traversing the elements [] array of the form, or by using document. getelementbyid ().

Source: http://www.w3school.com.cn/jsref/dom_obj_submit.asp

Differences between submit and button in HTML

Submit is a special case of a button and also a kind of button. It automatically integrates the submit action. If the form needs to be processed (including input verification) by clicking the submit button and then submitted, you must change the submit to the button to cancel the automatic submission. Otherwise, it will result in two submissions. For dynamic web pages, that is, two database operations. Alternatively, return true or false is added for verification when submit is used. You can also use jquery form events for processing. The specifications are as follows:

 

Jquery event-submit () method definition and usage

When a form is submitted, a submit event occurs.

This event applies only to form elements.

The submit () method triggers the submit event, or specifies the function that runs when a submit event occurs.

Bind a function to the submit event syntax
$(selector).submit(function)
Parameters Description
Function Optional. Specifies the function that runs when a submit event occurs.

 

 

Source: http://www.w3school.com.cn/jquery/event_submit.asp

Form submission problems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.