0

I have a input type="text" and next to that a button which opens up a calendar on click. When a value is selected in calendar textbox ix populated.

I would like to handle on change of textbox to enable other controls.

change, input etc events are triggered only if use manually enters values in the text box. But in my case I am not touching the input textbox.

Thanks.

Lelio Faieta
  • 6,457
  • 7
  • 40
  • 74
hima
  • 610
  • 3
  • 10
  • 24
  • Possible duplicate of [Detect all changes to a (immediately) using JQuery](https://stackoverflow.com/questions/1948332/detect-all-changes-to-a-input-type-text-immediately-using-jquery) – misorude Aug 06 '19 at 10:41

1 Answers1

0

Use jquery change event.

$("input").change(function(){
  //do something
})

Update:

As .change event doesn't get fired when you change value using any javascript method, there is a work around.

When you change the date, you can trigger an event to the input element like $("input").keyup() and listen using:

$("input").keyup(function(){
    // input updated
  })

codepen example: https://codepen.io/azharuddinkhan8898/pen/MNrLad

  • https://api.jquery.com/change/: _“Note: Changing the value of an input element using JavaScript, using .val() for example, won't fire the event.”_ - OP is likely talking about exactly such a case here, so this does _not_ solve the problem. – misorude Aug 06 '19 at 10:47