-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
42 lines (36 loc) · 1.25 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Mascara para o Telefone
function mascararTelefone() {
var telefone = document.getElementById('telefone');
var valor = telefone.value;
valor = valor.replace(/\D/g, '');
valor = valor.replace(/^(\d{2})(\d)/g, '($1) $2');
valor = valor.replace(/(\d)(\d{4})$/, '$1-$2');
telefone.value = valor;
}
// Mascara para o CPF
function mascararCPF() {
var cpf = document.getElementById('cpf');
var valor = cpf.value;
valor = valor.replace(/\D/g, '');
valor = valor.replace(/^(\d{3})(\d)/g, '$1.$2');
valor = valor.replace(/^(\d{3})\.(\d{3})(\d)/g, '$1.$2.$3');
valor = valor.replace(/^(\d{3})\.(\d{3})\.(\d{3})(\d)/g, '$1.$2.$3-$4');
cpf.value = valor;
}
// Mascara para o CEP
function mascararCEP() {
var cep = document.getElementById('cep');
var valor = cep.value;
valor = valor.replace(/\D/g, '');
valor = valor.replace(/^(\d{5})(\d)/g, '$1-$2');
cep.value = valor;
}
function verificarCheckbox() {
var checkbox = document.getElementById("checkbox");
var resultadoLabel = document.getElementById("resultado");
if (checkbox.checked) {
resultadoLabel.textContent = "Sim";
} else {
resultadoLabel.textContent = "Não";
}
}