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?'; };
});