Previously, I wrote a post that asked questions as a beforeunload event when I left the page during the registration, exceptions I'm asking you again because there's a situation.
$("#form").on("change",function(e){
if($(e.target).val().length > 0) {
$(window).on("beforeunload", function (){
If you leave the "return" page, the contents you are creating will not be saved.";
});
} } else {
$(window).off("beforeunload");
}
});
I organized the code in this way, but the input or select inside the form works well with change, but the part that uses the datepicker inside does not seem to be recognized as a change event because it has a value of $("#datepicker"). Is there an event that recognizes the part that gives a value with jquery as change or operates whenever the val().length of that value is > 0 or higher?
jquery
Pull trigger when certain events (such as when the date picker window is closed) are executed in that datepicker.
// Conceptual similar code. I didn't test it.
$('#datepicker input').on('focus', function () {
$('#form').trigger('change');
});
© 2024 OneMinuteCode. All rights reserved.