Time for action – performing client-side validations
Let us see how we can create a User Registration form with regular JSF validators and converters, and perform validations using the PrimeFaces Client-side Validation framework, by performing the following step:
- Create a User Registration form and enable client-side validations by setting the
validateClient
attribute totrue
:<h:form id="registrationForm"> <p:panel header="User Registration"> <h:panelGrid columns="3"> <p:outputLabel value="EmailId:*"/> <p:inputText id="emailId" value="#{userController.registerUser.emailId}" label="EmailId" required="true"> <f:validateRegex pattern="^[_A-Za-z0-9-\+]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,})$" /> </p:inputText> <p:message for="emailId"/> ...