Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery change event not firing for input field

Tags:

jquery

events

I'm trying to remove an alert on a form when a user fixes an empty field. My generalized code works for all input elements where the user has to type in the field, but my input that has a popup calendar does not fire the "change" event if the date is placed in the field by the system. I thought the change event fired when the field lost its focus?

        $("#my_input").change(function() {
            $(".StatusBox").html("");
            $(this).unbind("change");
        });

I have another piece of code that runs after this and changes the input field(user clicking on a calendar date and therefore updating the input). Shouldn't that fire the change event?

like image 239
Jay McVety Avatar asked Mar 06 '15 15:03

Jay McVety


Video Answer


1 Answers

Use something like this, it always works.

$(function() {
    $("#my_input").on("change paste keyup", function() {
       alert($(this).val()); 
    });
});
like image 94
ucMedia Avatar answered Sep 28 '22 04:09

ucMedia