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.

3
  • 2
    I think this should work: yourinputelement.focus(); document.execCommand('selectAll', false); document.execCommand('insertText', false, 'your text'); Commented May 18, 2018 at 21:03
  • Thanks @wOxxOm Thank solved my problem ;) Commented May 18, 2018 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. Commented May 18, 2018 at 21:22

1 Answer 1

1
yourinputelement.focus();
document.execCommand('selectAll', false);
document.execCommand('insertText', false, 'your text');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.