In my JavaScript function I give all input-, textarea- and select-fields the actual value as an initial_value:
$('input, textarea, select').each(function (i) {
$(this).data('initial_value', $(this).val());
});
So I can check by keyup if there are any changes in a field:
$("body").on("keyup", 'input, textarea, select', function() {
if ($(this).val() != $(this).data('initial_value')) {
handleFormChanged();
changeMessage();
}
});
But also I want to check by keyup if the changes were deleted out of the fields. My idea was to check with an else if if the value in all fields is equal to the initial_value in all fields. It is important to know if really the value in ALL fields is equal to the initial_value. But it doesn´t work. Any better ideas? Thanks a lot!
Aucun commentaire:
Enregistrer un commentaire