Last active
June 11, 2024 20:29
-
-
Save marcoscastro/7887900ceebe9e223dce to your computer and use it in GitHub Desktop.
HTML 5 - Validando formato de CPF
This file contains hidden or 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
<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> |
só colocar type="number" ao invés de text.
Basta colocar o type="number_format"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uma das formas de garantir apenas números no input type="text"
https://stackoverflow.com/a/28838789