Client Side Validation - Bean Validation

Client Side Validation Framework is integrated with Bean Validation Specification.

Validate

Source

<h:form>
    <p:panel header="Validate">
        <p:messages />

        <h:panelGrid columns="4" cellpadding="5">
            <h:outputLabel for="name" value="Name: (@Size(min=2,max=5))" />
            <p:inputText id="name" value="#{validationBean.name}" label="Name"/>
            <p:message for="name" />
            <h:outputText value="#{validationBean.name}" />

            <h:outputLabel for="age" value="Age: (@Min(10) @Max(20))" />
            <p:inputText id="age" value="#{validationBean.age}" label="Age"/>
            <p:message for="age" />
            <h:outputText value="#{validationBean.age}" />

            <h:outputLabel for="amount" value="Amount: (@DecimalMax('99.9'))" />
            <p:inputText id="amount" value="#{validationBean.amount}" label="Amount"/>
            <p:message for="amount" />
            <h:outputText value="#{validationBean.amount}" />

            <h:outputLabel for="amount2" value="Amount: (@Digits(integer=3,fraction=2))" />
            <p:inputText id="amount2" value="#{validationBean.amount2}" label="Amount 2"/>
            <p:message for="amount2" />
            <h:outputText value="#{validationBean.amount2}" />

            <h:outputLabel for="pattern" value="Pattern: (@Pattern(regexp="^[-+]?\\d+$")))" />
            <p:inputText id="pattern" value="#{validationBean.pattern}" label="pattern"/>
            <p:message for="pattern" />
            <h:outputText value="#{validationBean.pattern}" />

            <h:outputLabel for="checked" value="Assert: (@AssertTrue)" />
            <p:selectBooleanCheckbox id="checked" value="#{validationBean.checked}" />
            <p:message for="checked" />
            <h:outputText/>

            <h:outputLabel for="psstDate" value="Date (@Past)"/>                                
            <p:inputText id="psstDate" value="#{validationBean.pastDate}">
                <f:convertDateTime pattern="MM/dd/yyyy" />
            </p:inputText> 
            <p:message for="psstDate" />
            <h:outputText/>

            <h:outputLabel for="futureDate" value="Date (@Future)"/>                                
            <p:inputText id="futureDate" value="#{validationBean.futureDate}">
                <f:convertDateTime pattern="MM/dd/yyyy" />
            </p:inputText> 
            <p:message for="futureDate" />
            <h:outputText/>

        </h:panelGrid>

        <p:commandButton value="Save" ajax="false" icon="ui-icon-check" validateClient="true" />
    </p:panel>
</h:form>