I have a web page with two radio buttons and two corresponding text boxes. Both are part of a single radio group. The page also has a submit button.
o Radio1 [Textbox1] o Radio2 [Textbox2]
|Submit|
When I select Radio1 and click on submit, validation error messages are being displayed if errors occur. These are gloabl error messages which appear on top of the page for all the fields. I have used validatorMessage attribute of
<h:inputText>
to display the errors and
<f:validateRegex pattern="(^[0-9]{1,15}$)" />
to validate the error. Also I have
<h:messages class="errors" style="color:red;" layout="table" />
on top of the xhtml page.
My requirement is that when I click on Radio2, I need the Radio1's error messages to disappear, since they are irrelevant for Radio2. Similarly vice versa.
Is there a way to clear Radio1's error messages using AJax or JS whenever Radio2 is selected?
Updated with radio code:
<t:selectOneRadio id="options" value="#{reqscope.selectedRadio}" layout="spread">
<f:selectItem itemValue="radio1" itemLabel="Policy number" />
<f:selectItem itemValue="radio2" itemLabel="Customer ID" />
</t:selectOneRadio>
<t:radio for="options" index="0" name="search_by1" onclick="searchSelected()">