This is an example of an HTML5 form with
required
and validate
attributes that also uses
visibleIf
to dynamically hide and show form fields according to other form
field values (in this case, the form will show a Postal Code
field if the country chosen is Canada, or a zip code field if the country chosen is the United States. Note that the validation only happens on those fields that
are visible, since the visibleIf
library sets them to be disabled
, which prevents validation.
Back to User Agent Man HTML5 Forms article