Primeiro commit
Signed-off-by: Rodrigo Martins <rodrigo.sousa.577@gmail.com>
This commit is contained in:
commit
a1beb6a2e0
425 files changed
+193665
No files matched your search
@@ -0,0 +1,35 @@
|
||||
// formatacoes.js
|
||||
|
||||
function formatarCPF(cpf) {
|
||||
cpf = cpf.replace(/[^\d]/g, "");
|
||||
return cpf.replace(/(\d{3})(\d{3})(\d{3})(\d{2})/, "$1.$2.$3-$4");
|
||||
}
|
||||
|
||||
function formatarTelefone(telefone) {
|
||||
telefone = telefone.replace(/[^\d]/g, "");
|
||||
return telefone.replace(/(\d{2})(\d{5})(\d{4})/, "($1) $2-$3");
|
||||
}
|
||||
|
||||
// Função para aplicar a formatação em uma tabela
|
||||
function formatarTabela(tabelaSeletor, cpfColuna, telefoneColuna) {
|
||||
$(tabelaSeletor + ' tr').each(function() {
|
||||
var cpf = $(this).find('td:nth-child(' + cpfColuna + ')').text();
|
||||
var telefone = $(this).find('td:nth-child(' + telefoneColuna + ')').text();
|
||||
|
||||
if (cpf) {
|
||||
$(this).find('td:nth-child(' + cpfColuna + ')').text(formatarCPF(cpf));
|
||||
}
|
||||
|
||||
if (telefone) {
|
||||
$(this).find('td:nth-child(' + telefoneColuna + ')').text(formatarTelefone(telefone));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Função para aplicar a formatação em um elemento específico (client_details.php)
|
||||
function formatarElemento(elementoSeletor, valor) {
|
||||
if (valor) {
|
||||
$(elementoSeletor).text(formatarTelefone(valor));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user