I have a form with one field called emai
has a very simple validation required = true
. now when I click on the button bellow it performs AJAX callback. I wonder anyway to make the validation done on the client side without calling the server?
<h:form class="lfrm" id="lfrm">
<p:panel id="lpanel" header="Login">
<p:messages id="lmessages" showDetail="true" autoUpdate="true"/>
<h:panelGrid id="lgrid" columns="2" cellpadding="5">
<h:outputText value="Email: *" />
<p:inputText styleClass="email"
id="lemail"
value="#{Registration.user.email}"
required="true" requiredMessage="Email is required">
</p:inputText>
<p:commandButton process="lemail"
value="Sign in"
immediate="true"
validateClient="true"/>
</p:panel>
</h:form>
Add the following configuration in web.xml
<context-param>
<param-name>primefaces.CLIENT_SIDE_VALIDATION</param-name>
<param-value>true</param-value>
</context-param>
Also if you set ajax to false, the current form where the component lives is sent. ie the form which contains the p:commandButton. If ajax used, choose what you want to process. use the following tag to process the fields to the command button
<p:commandButton process="@form" ...... />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.