execute the function even if the input is disabled - Jquery -javascript [closed]

-1

I wanted to run an alert if the input submit even though the inputs are disabled follow the code.

<input type="submit" value="Cadastrar" class="col-md-12 col-xs-12 col-lg-12" id="submitCadastro" disabled="">

I tried with the event click and with the event mouseente and only occurs when the input button is enabled, I would like it to execute only when it is unoccupied

    
asked by anonymous 20.09.2018 / 15:14

1 answer

0

I made a small solution with jQuery to help you, you do not need 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;
        }
    });

});
    
20.09.2018 / 16:01