W3C home > Mailing lists > Public > public-html@w3.org > May 2014

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

From: Jukka K. Korpela <jukka.k.korpela@kolumbus.fi>
Date: Mon, 05 May 2014 08:22:03 +0300
Message-ID: <53671FFB.7070508@kolumbus.fi>
To: public-html@w3.org
2014-05-04 18:21, Šime Vidas wrote:
>  there appears to be no standard way to retrieve the original 
> disabled-state of the button (the state from the HTML source)

It is admittedly unsystematic that we have the defaultChecked and 
defaultValue properties but nothing of that case corresponding to the 
disabled state. Although adding defaultDisabled might seem to be a 
simple change, I don't think it's really needed.

In the relatively rare situations where you need to know the initial 
state, you can use an attribute like data-default-disabled for it. 
Alternatively, and perhaps better, you can add a property like that 
dynamically. To keep it simple, you would simply add the property to all 
fields, with its value copied from the value of the disabled property.

> 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.
In the approach I'm suggesting, you would set the value of the disabled 
property of each field to the value of the data-default-disabled property.

Yucca, http://www.cs.tut.fi/~jkorpela/
Received on Monday, 5 May 2014 05:22:32 UTC

This archive was generated by hypermail 2.4.0 : Saturday, 9 October 2021 18:46:09 UTC