Html5 form validation with required and disabled element -


i realize should never disable element , require it, because how user make valid if it's disabled?

however, have <select> of products want users choose from. when select 1 of products <select> product's models populated, enabled, , required only if product has 1 or more models. otherwise, model select disabled , emptied.

while think code perfect , can make model dropdown never disabled , required @ same time, i'm not perfect. so, form able submitted <select> disabled , required?

update

taken w3.org:

constraint validation: if element required, , value idl attribute applies , in mode value, and element mutable, , element's value empty string, element suffering being missing.

looked specific of means "mutable".

a form control can designated mutable.

note: determines (by means of definitions , requirements in specification rely on whether element designated) whether or not user can modify value or checkedness of form control, or whether or not control can automatically prefilled.

selects don't have value, determined it's options.

the select element not have value; selectedness of option elements used instead.

so, think means if <select> element disabled , required, form considered valid?

http://www.w3.org/tr/html5/forms.html#enabling-and-disabling-form-controls:-the-disabled-attribute:

constraint validation: if element disabled, barred constraint validation.

http://www.w3.org/tr/html5/forms.html#barred-from-constraint-validation:

a submittable element candidate constraint validation except when condition has barred element constraint validation.

and finally, list of constraint validation steps, http://www.w3.org/tr/html5/forms.html#constraint-validation:

3.1: if field not candidate constraint validation, move on next element.


that means, disabled element “passed over” when form validity checked.

it doesn’t trigger errors, , has no influence whatsoever on validation state of form belongs to.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -