Mariah
Mariah

Reputation: 1103

primefaces inputtext anycharacter except whitespace

how I can make for an inputText accept any letter except allow spaces and special characters?

i tried like this, but is not working...

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
template="/private/commonHomeTemplate.xhtml">
<ui:define name="content">
<h:form id="someForm">
<p:growl id="msg" showDetail="true" life="3000" autoUpdate="true"/>
<p:panelGrid style="100%">
<p:row>
<p:column style="350px">title</p:column>
<p:column>
<h:inputText value="#{someBean.somePropertie}" >
<f:validateRegex pattern="[a-zA-Z]+"/>
</h:inputText>
</p:column>
</p:row>
</p:panelGrid>  
</h:form>
</ui:define>
</ui:composition>

Thank you

Upvotes: 2

Views: 2237

Answers (1)

amedeo avogadro
amedeo avogadro

Reputation: 595

Your regular expression seems to be fine, to see error validation you have to include the <h:message /> tag inside the <h:form /> tag

<h:inputText value="#{someBean.somePropertie}" id="userInputField">
    <f:validateRegex pattern="[a-zA-Z]+"/>
</h:inputText>

<h:message for="userInputField" />

Remember that you cannot use nested <h:form /> inside a JSF page.

Upvotes: 3

Related Questions