Reset button tip-Why cannot I reset the form data? tip form

Source: Internet
Author: User

Reset button tip-Why cannot I reset the form data? tip form

When I first learned html, some people may encounter a problem, that is, why does the reset button in the editing Page always fail to work and data is not cleared? Next, let's explain the reason.

Reset object

The Reset object represents a Reset button in the HTML form.

Each time a <input type = "reset"> tag appears in an HTML form, 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 theirDefault Value. The default value is specified by the HTML value Attribute or the defaultValue attribute of JavaScript.

The reset button triggers the onclick handle before the form is reset, And the handle can be canceled by returning fasle.

See the Form. reset () method and Form. onreset event handle.

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

Important

It is the default value mentioned above. As the name suggests, the editing page is the page that has already filled in the data, which contains the default data filled in before, that is to say, there is a default value in the input box, but it is not empty data as before, so when you click the reset button, it will only return to the default value you entered for the first time, data is not cleared.

Ps: At the beginning, I also encountered this problem, which was hard to understand. Hope to help the comrades who are learning the same issues as me.

 

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.