Input disable not found in serialize

0

If the form I have is validated, I disable the form, like this:

 $("#Editar :input").prop("disabled", true);

But I have function to serialize, and if I have forms disabled, they can not find the value. Is there any way to disable fields, but still find them?

This is the function I use, it compares the form when it is loaded, and the form at the time of action, and because they are disabled, it does not find values.

   $(function () {
        var init_form = $('#Editar').serialize(); 
    $(':submit').click(function () { window.onbeforeunload = null; }); window.onbeforeunload = function () { var check_form = $('#Editar').serialize(); console.log(check_form); console.log(init_form); if (check_form === init_form) return null; return 'Os dados do formulário não foram salvos, deseja permanecer nesta página?'; };
 });

In the console, what appears in white is var check_form = $('#Editar').serialize(); the other not, how to fix?

    
asked by anonymous 04.10.2018 / 20:59

1 answer

1

The disable property does not actually read serialize, try changing the field property to readonly.

$('#inputId').prop('readonly', true);

This should solve your problem.

    
04.10.2018 / 21:35