New Understanding of Form reset method-javascript tips-js tutorial

Source: Internet
Author: User
The reset method of Form in HTML is used to clear the content entered by the user, in the past, I mistakenly thought that the reset method of Form in HTML is used to empty the values of input items such as input, in the past, I mistakenly thought it was simply to empty the values in input items such as input.

But this is not the case. The essence of the reset method is to restore the content in input items such as input to the value in the attribute value, rather than the "" null value.

This is what w3c says:

In an HTML form Each time a tag appears, a Reset object is created.

When the reset button is clicked, the values of all input elements in the form containing it are reset to their default values. The default value is specified by the HTML value Attribute or the defaultValue attribute of JavaScript.

In actual situations, we often need to implement form reset when editing a specific content. However, the value Attribute of input items such as input may have been assigned a value, therefore, reset only initializes the form to this value.

In this case, we can only use javascript to set the value attribute of input items such as input to null to achieve the reset effect.
Related Article

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.