How to call onblur from this submit?

0
$("#more").submit(function (event) {
    event.preventDefault();

    alert('estou aqui');
    var link = $("#link").val();
    var date = $("#date-foundation").val();

    var validation = true;

    if (link === null || link === '') {
        $("#link").addClass("input-required");
        validation = false;
    }

    if (validation === true) {
        $.ajax({
            url: './model/functions/link_repeat.php',
            type: 'POST',
            data: {link: link},
            success: function (data) {
                alert(data);
                if (data === 'true') {
                    $("#link").addClass("input-required");
                    $("#alert-link").append("<span style='color:red'><b>Esse link já existe! Escolha outro!</b></span>");
                    return;
                }
            }
        });
    }
});
    
asked by anonymous 15.09.2016 / 16:09

1 answer

0

Perhaps the concept of onBlur is not clear. Home Check out the link for you to better understand the event generated by hovering over an object and the event after you change the value of an element ( onBlur x onChange in English )

See if what you need is this in your javascript file

var inputsAlterados = 0;

$('.classeParainputs').change(function () {
    inputsAlterados++;
});

$("#botaoGravar").submit(function () {
    if (inputsAlterados > 0) {
        /**
            Continuidade da lógica para salvar
        **/
    }
});
    
16.09.2016 / 00:07