如何使 inputText 接受除允许空格和特殊字符之外的任何字母?
我尝试过这样的操作,但不起作用...
<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>
谢谢
最佳答案
您的正则表达式似乎没问题,要查看错误验证,您必须包含 <h:message />
<h:form />
内的标签标签
<h:inputText value="#{someBean.somePropertie}" id="userInputField">
<f:validateRegex pattern="[a-zA-Z]+"/>
</h:inputText>
<h:message for="userInputField" />
请记住,您不能使用嵌套 <h:form />
在 JSF 页面内。
关于jsf - primefaces 输入文本 除空格外的任何字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26807058/