[whatwg] Comments on Web Forms 2.0 Working Draft

>
>
>>The custom validation could be done in onchange or oninput, but that may
>>turn out to be too often or too rare.
>>    
>>
>Why?
>  
>
Doing it on onchange will be to rare. If there is a CSS rule for 
:invalid, this rule should be applied as soon as the value of the 
control becomes invalid and not wait for the onchange event to be 
triggered (right?).

Doing it on oninput may turn out to be too often. Assume that I have a 
validation function that takes, say, 0.2 seconds to compute. If this 
function is called oninput, it has to be computed for each keypress and 
that makes typing slow. The UA may choose to only do the validation once 
in a while, e.g. once every x seconds, so that the :invalid rule is 
still applied, just a little delayed. Or if there are no :invalid rules, 
the UA may choose not to validate until e.g. form.validate() is called 
or control.validity is accessed.

A UA may implement this logic by internally setting a "dirty" bit on the 
control when the oninput event is triggered. Whenever the validity 
property is accessed by script and the dirty bit is on, the onvalidation 
event handler is called and the dirty bit is reset.

Also, onchange and oninput are not triggered by scripted changes to the 
control value. I think that an onvalidation event should be triggered by 
scripted changes, so that control.validity is always in sync with the 
actual validity of the control.


Christian

Received on Wednesday, 23 June 2004 13:32:43 UTC