happybuddha
happybuddha

Reputation: 1358

Fire Jquery text change when selecting prefilled value

I am copying over firstname into lastname field. This works well with new names on the page. However, after entering a few names the browser shows the history of names and if there are any prefilled names, or older names that are selected, then this function isn't fired. How could I update the lastName to whatever the firstName has been changed to ?

  $(document).ready(function() {
        $("#FName").change(function() {
        $("#LName").val($(this).val());
    });

(Ex., you begin with John, Jack when you enter J for the third time, it shows John and Jack as available names. Jquery change is not fired when selecting pre filled value )

There is a bug opened on this for FF : https://bugzilla.mozilla.org/show_bug.cgi?id=87943

Upvotes: 2

Views: 1122

Answers (1)

Rajaprabhu Aravindasamy
Rajaprabhu Aravindasamy

Reputation: 67217

Don't rely on change event at this situation, prefer input event. Because change event only get triggered when the focus got blurred out from the particular text box.

$(document).ready(function() {
    $("#FName").on('input',function() {
      $("#LName").val(this.value);
    });
});

Upvotes: 7

Related Questions