I have a register form in JSF and I want the validate if the new user agreed with the terms and conditions only after all the other fields from the form are valid. Is there any way to validate this in JSF? Here is a sample of my code.
<h:form id="registerForm">
<table>
//Other fields
<tr>
<td><h:outputText value="Username " /></td>
<td><h:inputText id="fusername"
value="#{registerUser.username}">
<f:validator for="fusername" validatorId="usernameValidator" />
</h:inputText></td>
<td><h:message for="fusername" style="color:red" /></td>
</tr>
<tr>
<td><h:outputText value="Password: " /></td>
<td><h:inputSecret id="fpassword"
value="#{registerUser.password}">
<f:validator for="fpassword" validatorId="passwordValidator" />
</h:inputSecret></td>
<td><h:message for="fpassword" style="color:red" /></td>
</tr>
<tr>
<td><h:outputText value="Repeat Password " /></td>
<td><h:inputSecret id="repeatPassword"
value="#{registerUser.repeatPassword}">
<f:validator for="repeatPassword" validatorId="repeatPasswordValidator"/>
<f:attribute name="originalPassword" value="fpassword" />
</h:inputSecret></td>
<td><h:message for="repeatPassword" style="color:red" /></td>
</tr>
<tr>
<td><h:selectBooleanCheckbox
value="#{registerUser.agreeTermsAndConditions}" required="true"/></td>
<td>I agree with the terms and condition.</td>
</tr>
<tr>
<td />
<td><h:commandButton action="#{registerUser.saveUser}"
value="Register" /></td>
</tr>
</table>
</h:form>
</f:view>