Last active
June 4, 2018 13:53
-
-
Save nosrednawall/904e4a70e2ad1ff332a60ac3d937c8c3 to your computer and use it in GitHub Desktop.
Validador regex para cpf e cnpj, apenas para quantidade de caracteres
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p:outputLabel value="Cpf/CNPJ " for="cpf" /> | |
<p:inputText id="cpf" value="#{seuBean.entitade.cpfCnpj}" | |
maxlength="20" required="true" | |
requiredMessage="Campo cpf não pode estar em branco" | |
validatorMessage="CPF inválido"> | |
<f:passThroughAttribute name="placeholder" value="Informe o seu CPF ou CNPJ" /> | |
<f:validateRegex | |
pattern="([0-9]{2}[\.]?[0-9]{3}[\.]?[0-9]{3}[\/]?[0-9]{4}[-]?[0-9]{2})|([0-9]{3}[\.]?[0-9]{3}[\.]?[0-9]{3}[-]?[0-9]{2})" /> | |
<f:ajax event="blur" render="messageCpf" /> | |
<p:message for="cpf" id="messageCpf" /> | |
</p:inputText> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment