Reputation: 448
I have a register form with multiple input text all the fields are required and some fields has validateRegex
and validator message like the input text of an email.
<h:form>
<p:outputLabel value="Login:" for="pseudo"/>
<p:inputText id="pseudo" value="#{customerMB.login}" title="Pseudo" required="true" validatorMessage="Enter a valid email" requiredMessage="Please enter your email.">
<f:validateRegex pattern="([^.@]+)(\.[^.@]+)*@([^.@]+\.)+([^.@]+)" />
</p:inputText>
<p:watermark for="pseudo" value="Enter you email address" />
</h:form>
I need to show only validator message and not the required message. I mean when I submit the form without filling the field the outputLabel is highlighted with red (that works fine ) but when I submit using a wrong form of email address it is not shown the validator message.
If i use <p:message for="pseudo">
it will show the required message too.
Upvotes: 0
Views: 3469
Reputation: 2985
I have a project which has a email validation and here what I did:
<p:inputText id="pseudo" value="#{customerMB.login}"title="Pseudo" required="true" validatorMessage="Enter a valid email" requiredMessage="">
<f:validateRegexpattern="^[_A-Za-z0-9-\+]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,})$" />
<p:ajax event="blur" update="growl"/>
</p:inputText>
It shows the validation message right after leaving the field.
Upvotes: 2
Reputation: 4044
Put an empty string as validatorMessage, like this:
<p:inputText id="pseudo" value="#{customerMB.login}" title="Pseudo" required="true" validatorMessage="Enter a valid email" requiredMessage="">
<f:validateRegex pattern="([^.@]+)(\.[^.@]+)*@([^.@]+\.)+([^.@]+)" />
</p:inputText>
Upvotes: 1