previous | index | next

Validator Tag Examples

Suppose a credit card number field requires at least 13 characters:
     <h:inputText id="card" value="#{payment.card}">
        <f:validateLength minimum="13"/>
     </h:inputText>

If the input is required but there is no minimum length, use the required attribute that is supported by all input tags:

     <h:inputText id="date" value="#{payment.date}" required="true"/>

Numerical input values may be required to be in a given range. Here is a validator that checks that the supplied value is ≥ 10 and ≤ 10000:

     <h:inputText id="amount" value="#{payment.amount}">
        <f:validateLongRange minimum="10" maximum="10000"/>
     </h:inputText>

previous | index | next