0

I am writing a script/chrome extension to automate a process. I want to change a input field. I tried to do it with changing the value of html input field. But the problem I am facing is I can't make the field dirty which is restricting to make the button enable as field are untouched.

I have tried to make field focus and blur. Not worked.

Change AngularJS input text value using javascript Also tried this one.

The button doesn't get enabled.

Do any body have any solutions?

Thanks.

Muzammil Bilwani
  • 146
  • 4
  • 14
  • 2
    I think this should work: yourinputelement.focus(); document.execCommand('selectAll', false); document.execCommand('insertText', false, 'your text'); – wOxxOm May 18 '18 at 21:03
  • Thanks @wOxxOm Thank solved my problem ;) – Muzammil Bilwani May 18 '18 at 21:17
  • In angular 1, I create a watch on an model attribute to flip the dirty flag. I kept a dirty flag global on the page . Enable/disable button based on dirty flag. – Leng May 18 '18 at 21:22

1 Answers1

1
yourinputelement.focus();
document.execCommand('selectAll', false);
document.execCommand('insertText', false, 'your text');
Md. Abu Taher
  • 17,395
  • 5
  • 49
  • 73
Muzammil Bilwani
  • 146
  • 4
  • 14