Locale

Language
English
English
English
French
German
German
German
Italian
Korean
Spanish
Catalan
Dutch
Portuguese
Portuguese
Arabic
Arabic
Bulgarian
Bangla
Bosnian
Czech
Greek
Persian
Finnish
Danish
Hindi
Indonesian
Croatian
Japanese
Hungarian
Hebrew
Georgian
Central Kurdish
Khmer
Kyrgyz
Kazakh
Lithuanian
Latvian
Malay
Norwegian
Polish
Romanian
Russian
Slovak
Slovenian
Serbian
Serbian
Swedish
Thai
Turkish
Ukrainian
Uzbek
Vietnamese
Chinese
Chinese

Input Style

Free Themes

Built-in component themes created by the PrimeFaces Theme Designer.

Saga Saga
Vela Vela
Arya Arya

Legacy Free Themes

Luna Amber Luna Amber
Luna Blue Luna Blue
Luna Green Luna Green
Luna Pink Luna Pink
Nova Nova
Nova Nova Alt
Nova Nova Accent

Client Side Validation Complex

This examples shows how you can implement complex validation on the clide side like conditional validation or "connected" validation over mulitple inputs.
If you select "Name required", you have to set content in the "Name" input.


<script>
    //<![CDATA[
    PrimeFaces.validator['MyComplexValidator'] = {

        validate: function (element) {
            let nameRequiredPf = PF('nameRequired');
            let namePf = PF('name');

            if (nameRequiredPf.isChecked() && namePf.getValue().length === 0) {
                PrimeFaces.validation.ValidationContext.highlight(namePf);
                PrimeFaces.validation.ValidationContext.addMessage(namePf, {
                    summary: 'Validation Error',
                    detail: 'A name is required!'
                });
            } else {
                PrimeFaces.validation.ValidationContext.unhighlight(namePf);
            }
        }
    };
    //]]>
</script>

<div class="card">
    <h:form id="form">
        <p:outputPanel pt:data-p-val="MyComplexValidator">
            <p:messages showDetail="true">
                <p:autoUpdate/>
            </p:messages>

            <h:panelGrid id="grid" columns="3" cellpadding="5">
                <p:outputLabel for="@next" value="Name required"/>
                <p:selectBooleanCheckbox id="nameRequired" widgetVar="nameRequired"
                                         value="#{complexValidationView.nameRequired}"/>
                <p:message for="@previous"/>

                <p:outputLabel for="@next" value="Name"/>
                <p:inputText id="name" widgetVar="name" value="#{complexValidationView.name}" label="Name"/>
                <p:message for="@previous"/>

                <p:outputLabel for="@next" value="Accept Terms And Conditions"/>
                <p:selectBooleanCheckbox id="terms" value="#{complexValidationView.acceptTermnsAndCondition}"/>
                <p:message for="@previous"/>
            </h:panelGrid>

            <p:defaultCommand target="btnAjax"/>

            <p:commandButton value="Non-Ajax" ajax="false" icon="pi pi-check" validateClient="true"
                             action="#{complexValidationView.doNonAjax()}" style="margin-right:10px"/>
            <p:commandButton value="Ajax" id="btnAjax" update="@form" icon="pi pi-check" validateClient="true"
                             action="#{complexValidationView.doAjax()}" style="margin-right:10px"/>
            <p:commandButton value="Disabled (without CSV)" ajax="false" icon="pi pi-check"
                             action="#{complexValidationView.doNonAjaxWithoutCsv()}" style="margin-right:10px"/>
        </p:outputPanel>
    </h:form>
</div>