W3C home > Mailing lists > Public > whatwg@whatwg.org > October 2006

[whatwg] forms-lite testbed

From: Matthew Raymond <mattraymond@earthlink.net>
Date: Mon, 30 Oct 2006 19:32:58 -0500
Message-ID: <454699BA.3000307@earthlink.net>
Lachlan Hunt wrote:
> Actually, conditionally required fields would be a very nice addition. 
> I built this site earlier this year, which has conditionally required 
> fields.
> 
> https://www.edentiti.com/create/details.jsf
> 
> See the Postal Address section.  It's required unless it's the same as 
> the residential address.  If you check the "Use residential address" 
> checkbox, the fields are no longer required.  If you uncheck it again, 
> they are.  The JS updates the fields as soon as you check or uncheck the 
> box.

   In the case you listed, the scripting is minimal. You would use
something like this:

| <input [...] onforminput="required=!use_res.checked">

   The equivalent in Forms-Lite would be this:

| <input [...] needed="use_res = false">

   While the formula in the latter is easier to understand for
beginners, scripting is more flexible:

| <input [...] onforminput=
| "required=!use_res.checked; disabled=use_res.checked;">

   You could turn any binary attribute into one that takes a formula. I
just don't see a clear advantage in it. In the best cases, you're just
creating a new, simpler scripting language. In the worst case scenario,
you end up implementing something like |onformchange| or |onforminput|
anyways due to the limitations of the formulas.
Received on Monday, 30 October 2006 16:32:58 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:49 UTC