Hello,
I am having problem with required=true validation which is applied on disabled fields.
I have an a4j:commandButton and two dropdowns containing list of states and list of countries inside a form. Both the dropdowns have required="true" validation applied. state dropdown is enabled and country dropdown is disabled by default by using the tag attribute disabled="true" as shown below:
<h:selectOneMenu value="#{states}" required="true">
<f:selectItems>
</h:selectOneMenu>
and
<h:selectOneMenu value="#{countries}" disabled="true" required="true">
<f:selectItems>
</h:selectOneMenu>
Scenario# 1: click on the a4j:commandButton without selecting anything in the state dropdown. result: required field validation error for state dropdown which is expected
Now on clicking a radio button (outside the form), state dropdown is disabled and country dropdown is enabled using jquery/javascript as shown below:
$j('#stateDropdown').attr('disabled', 'disabled');
$j('#countryDropdown').removeAttr('disabled');
Scenario# 2: click on the a4j:commandButton without selecting anything in the country dropdown. result: required field validation error for both state and country dropdowns. However, only validation error for country dropdown was expected.
the html code generated by for <h:selectOneMenu>
tag on runtime:
for dropdown disabled using jsf tag attibute: <select disabled="disabled">...</select>
for dropdown disabled using jquery: <select disabled="">...</select>
Does anyone have any idea why jsf is validating the fields disabled by jquery?