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
| body { | |
| font-family: Arial, sans-serif; | |
| background-color: #f7f7f7; | |
| display: flex; | |
| flex-direction: column; | |
| align-items: center; | |
| padding: 20px; | |
| } | |
| .container { |
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
| function formatarRG(campo) { | |
| // Remove caracteres não numéricos | |
| var rg = campo.value.replace(/\D/g, ''); | |
| // Adiciona pontos e traço conforme o usuário digita | |
| rg = rg.replace(/(\d{2})(\d)/, '$1.$2'); | |
| rg = rg.replace(/(\d{3})(\d)/, '$1.$2'); | |
| rg = rg.replace(/(\d{3})(\d{1,2})$/, '$1-$2'); | |
| // Verifica se o último dígito é X e adiciona a string de retorno |