公告
财富商城
积分规则
提问
发文
2019-06-26 07:33发布
三岁会撩人
I need to allow only alphabetic characters [A-Z,a-z] in a PrimeFaces inputText field.
[A-Z,a-z]
How can I do this?
If you need to avoid characters in the view (input text) you can user p:keyFilter tag as below
<p:inputText id="apePat" placeholder="Apellido Paterno" value="#{actualizaDatos.user.apePat}" autocomplete="off" label="Apellido Paterno" validatorMessage="El campo apellido paterno es requerido"> <f:validateRequired/> <p:keyFilter regEx="/[a-zA-ZÀ-ú\\s\\' ]+/"/> </p:inputText>
Not specific to Primefaces but to underlying JSF:
You can use a regex validator on your input field:
<h:inputText value="#{myBean.myText}" > <f:validateRegex pattern="[a-zA-Z]+"/> </h:inputText>
This will work with p:inputText as well.
p:inputText
Adapt the regular expression to your functional requirements.
最多设置5个标签!
If you need to avoid characters in the view (input text) you can user p:keyFilter tag as below
Not specific to Primefaces but to underlying JSF:
You can use a regex validator on your input field:
This will work with
p:inputText
as well.Adapt the regular expression to your functional requirements.