0

I need to complete 3rd party form with several text inputs and selectors. Site is written using AngularJS 1.4.9. I prepared simple script to populate values in all required fields.

dict = {'input1' : 'value1', 'input2' : 'value2'};
for (field in dict) {document.getElementById(field).value = dict[field]};

Problem is that such approach doesn't trigger fields validation as no events were fired. Hense 'submit' button remains inactive. Is there a way to trigger change or other event from a script? Or probably there is even better way.

MjH
  • 1,170
  • 1
  • 8
  • 16

1 Answers1

0

Found the answer here: Trigger Change event when the Input value changed programmatically?

for (field in dict) {
  el = document.getElementById(field);
  el.value = dict[field];
  el.dispatchEvent(new Event('change'))};
MjH
  • 1,170
  • 1
  • 8
  • 16