Skip to content

Instantly share code, notes, and snippets.

@marcoscastro
Last active June 23, 2025 00:59
Show Gist options
  • Save marcoscastro/7887900ceebe9e223dce to your computer and use it in GitHub Desktop.
Save marcoscastro/7887900ceebe9e223dce to your computer and use it in GitHub Desktop.
HTML 5 - Validando formato de CPF
<html>
<head>
<title>Formato CPF</title>
<script src="script.js"></script>
</head>
<body>
<h3>Digite seu CPF:</h3>
<form name="cadastro">
<input type="text" name="cpf" \
pattern="\d{3}\.\d{3}\.\d{3}-\d{2}" \
title="Digite um CPF no formato: xxx.xxx.xxx-xx">
<input type="submit" value="Verificar">
</form>
</body>
</html>
@pedro98777
Copy link

Por gentileza saberia informar se existem como deixar os caracteres ponto e traço no campo de pré - enchimento de forma obrigatória?

por gentileza saberia informar se existem como deixar os caracteres ponto e traço no campo de pré-encimento de forma obrigatória?

imagem

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.inputmask/5.0.7/jquery.inputmask.min.js"></script> <script> $(document).ready(function(){ $('#cpf').inputmask("999.999.999-99"); }); </script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment