0

I have an input box (FieldTest) on HTML page, and a javascript function that invoked when the value of the input box is changed.

When changing the value of the input box manually, then the function is triggered, but when I change that by jquery $("#FieldTest").val('Some Text'); Then the onchange function is not triggered!

Any Idea??

Abusnake
  • 168
  • 11

2 Answers2

0

The onchange event is dispatched only if the user is typing in the input and the input loses focus. To dispatch it manually, simply use this line:

$(“#FieldTest”).change();

Caleb H.
  • 1,657
  • 1
  • 10
  • 31
0

Changing the value programmatically will not trigger an onChange event. You will have to create and dispatch one manually.

korona
  • 2,308
  • 1
  • 22
  • 37