I made a small solution with jQuery to help you, it is not necessary to block the submit button, follow the code below:
$(function () {
var $form = $("#ID_FORMULARIO"),
$ckTermosDeUso = $("#ID_CHECKBOX"),
$btnSubmeter = $("#ID_BOTAO_SUBMIT");
// Evento do Click do botão submeter
$btnSubmeter.on("click", function (e) {
// Evitando de executar o envio real do formulário.
e.preventDefault();
// Verificando se o checkbox foi marcado.
if ($ckTermosDeUso.is(":checked")) {
// Bloqueando o botão submeter para evitar vários click's
$btnSubmeter.attr("disabled", "disabled");
// Submetendo o formulário.
$form[0].submit();
return true;
}
else {
window.alert("Você deve aceitar os termos de uso!");
return false;
}
});
});
When the button is disabled, it will not perform any function. You must enable the button (by removing the disabled) and after firing click disable function. I still don’t understand your question.
– Jean Gatto
hi @jeangatto, I have a form and the button is enabled when the person agrees to the terms so I wanted to put an alert or a message saying that she forgot to agree to the terms in case she click the button without agreeing to the terms
– Cyber Hacker