-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
181 additions
and
7 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// alert('!ATENÇÃO! Em hipótese alguma coloque seus dados reais neste site. Preserve sua segurança digital!' | ||
function printarNumeroCartao(input) { | ||
// Remove todos os caracteres que não são dígitos | ||
input.value = input.value.replace(/\D/g, ''); | ||
|
||
// Limita o número de caracteres a 16 | ||
if (input.value.length > 16) { | ||
input.value = input.value.slice(0, 16); | ||
} | ||
|
||
// Formata o número do cartão adicionando um espaço a cada três caracteres | ||
var numFormatado = input.value.replace(/\D/g, '').replace(/(\d{4})(?=\d)/g, "$1 "); | ||
|
||
if (numFormatado == 0) { | ||
document.getElementById("print-numero").innerHTML = "123 *** *** ***" | ||
} else { | ||
document.getElementById("print-numero").innerHTML = numFormatado | ||
} | ||
} |
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