[whatwg] Webforms 2 comments - add .validation usage examples and equivalent BNF for new input TYPEs

Olav Junker Kjær olav at olav.dk
Fri Aug 13 09:05:48 PDT 2004


Brian Wilson wrote:
> I'm not sure if there 
> is  already DOM precedent for the binary value additive method of 
> determining  which validation errors have occurred, but for most this 
> will need more  explanation. 

I'm concerned about this too. I'm pretty sure many javascript authors have
never encountered bit fields. (Personally, I had never used the binary
operators in Javascript before using WF2.) It's more widely used in
lower-level languages, where people are used to thinking in binary.

I'm concerned that authors would write things like:

if (inputype.validity==form.ERROR_TOO_LONG) { 
	// nag
} else if (inputype.validity==form.ERROR_PATTERN_MISMATCH) {
	// nag
}

It's not intuitive to many javascripters why this won't work, especially
since it will work as intended most of the times, just not when both
errors are present. 

I'm not sure what the solution is, maybe an error-object with boolean
fields for each possible error, so you could write:

if (inputype.validity.isTooLong) { 
	// nag
} else if (inputype.validity.isPatternMismatch) {
	// nag
}

This seems a bit more scripter-friendly to me.

Olav Junker Kjær





More information about the whatwg mailing list