javascript - Jquery: Disable button if there is no change in form -
goal: disable button if there no changes in form.
i have working code function actually, problem can't work if have input[type=file] in form. if change file button still disabled.
would me please?
here's i've done far
$('#formedit').each(function(){   $(this).data('serialized', $(this).serialize()); }).on('change input', function(){   $(this).find('input:submit').attr('disabled', $(this).serialize() == $(this).data('serialized')); }); thank you.
the .serialize() method not work file input types can use new formdata('form'); below working code use case :
  $('#formedit').each(function() {     var form_data = new formdata('form');     $(this).data('serialized', form_data); }).on('change input', function() {     var form_data1 = new formdata('form');     $(this).find('input:submit').attr('disabled', form_data1 == $(this).data('serialized')); }); please refer jquery doc explore more on .serialize() method.
Comments
Post a Comment