when setting the value of an input with a content script (in a chrome extension), the value is reset when users clicks in input field

Viewed 7

I'm creating a chrome extension for internal use in my organization.

One of the features is to auto-fill some forms to save time.

normally, this should be done something like this:

document.getElementById("field1").value = "new value";

When doing this, the input field seems to behave as expected and displays the new value. However, when a users clicks in the field, it becomes empty again. Furthermore, if i try to submit the form without clicking in the field, it displays an error message as if the field was empty.

I also tried to dispatch an input event on the field like this:

document.getElementById("field1").dispatchEvent(new Event("input", {composed: true, bubbles: true, cancelable: false}));

But it doesn't help.

0 Answers
Related