Skip to content

Commit

Permalink
Personalização dos checkboxes e radios
Browse files Browse the repository at this point in the history
  • Loading branch information
BiancaFSilva authored Oct 2, 2024
1 parent 35760a3 commit 44347b5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fj-tech/src/js/fichas/cadastra_voluntario.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ let nomeCompleto = document.getElementById("nomeCompletoDoVoluntario");
let cpfVoluntario = document.getElementById("cpfDoVoluntario");
let emailVoluntario = document.getElementById("emailDoVoluntario");
let telefoneVoluntario = document.getElementById("telefoneDoVoluntario");
let sexoVoluntario = document.getElementById("sexoDoVoluntario");

// Endereço
let cepVoluntario = document.getElementById("cepDoVoluntario");
let logradouroVoluntario = document.getElementById("enderecoDoVoluntario");
Expand Down
24 changes: 24 additions & 0 deletions fj-tech/src/js/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,30 @@ document.querySelectorAll("input").forEach(input => {
if (input.type === "checkbox" || input.type === "radio") {
input.classList.remove("border-0");
input.classList.add("border", "border-opacity-75");

input.addEventListener("focus", () => {
if (input.type === "checkbox") {
input.addEventListener("change", () => {
if (input.checked) {
input.classList.add("bg-danger");
} else {
input.classList.remove("bg-danger");
}
});
}

if (input.type === "radio") {
input.addEventListener("change", () => {
document.querySelectorAll(`input[name="${input.name}"]`).forEach(radio => {
if (radio.checked) {
radio.classList.add("bg-danger");
} else {
radio.classList.remove("bg-danger");
}
});
});
}
});
}
});

Expand Down

0 comments on commit 44347b5

Please sign in to comment.