Function window.onbeforeunload

0

I have this function in my form But I do not have a button submit , but I have a button that sends the data, and when I click on it, it appears this message of the function below, how can I put an exception? Or something like this, this button does the submit function, but it is not of type="submit"

  $(function () {
    var init_form = $('#model').serialize(); // Result example: "name=&email=&message=" // Cancel event onbeforeunload when Submit 
   $(':submit').click(function () { window.onbeforeunload = null; }); window.onbeforeunload = function () { var check_form = $('#model').serialize(); if (check_form === init_form) return null; return 'Os dados do formulário não foram salvos, deseja permanecer nesta página?'; };
});
    
asked by anonymous 05.10.2018 / 20:56

0 answers