Is there no standard DOM API for retrieving the original disabled-state of a form field?

If I have a button in my HTML source code:

    <button disabled>Lorem ipsum</button>

and (later) enable the button with JavaScript:

    button.disabled = false;

then there appears to be no standard way to retrieve the original
disabled-state of the button (the state from the HTML source), i.e.
button.getAttribute('disabled') returns null (instead of e.g. an empty
string or "disabled").

**Why I need this:**

I have a form which has an initial state defined by the HTML source code:

 * some buttons are enabled, some buttons are disabled

The visitor starts interacting with the form. My JavaScript logic will
enable/disable various buttons based on user's interaction.

Now, if the user refreshes the page (e.g. by pressing F5), I would like to
revert the form to its initial state. I can run form.reset() on
"DOMContentLoaded" to empty the form fields, but the buttons will not be
re-initialized, i.e. a button that is supposed to be disabled initially,
may retain its enabled state after the page refresh.

I could explicitly re-initialize my buttons in "DOMContentLoaded" but for
that I would need to retrieve the original disabled-states (the states from
the HTML source code) and there appears to be no standard way to do this.

Received on Sunday, 4 May 2014 15:22:09 UTC