HTML form filled out by javaScript from chrome console disappears

Viewed 153

I want to fill out html forms on a third party website by auto generating javascript code which manipulates DOM from Chrome console:

document.getElementById("g_address").value = "abcdefg"

First step works, javascript applies changes to input field.

However, if I press submit from console or manually, all the filled out data in the input fields disappears. The same happens if I start typing manually in any input field.

My question - is it the website which prevents me from doing it like this or is it in general not possible to this way.

1 Answers

It's impossible to say what's happening without any information about the site in question. I doubt the site is deliberately detecting and/or circumventing your effort, but it wouldn't be uncommon for a web site or app to have its own internal representation of the form values in memory, independent of the html inputs, such that the app state, not the DOM, is the source of truth for the values.

Keystrokes on the inputs might be updating the app state, which in turn triggers a re-render of the DOM to display the new value for that input.

Because you're bypassing those interactions the app doesn't know about your changes and they don't get recorded. Then, when you subsequently type in an input the app updates the DOM, setting the input to its last known value, which doesn't include your changes.

Related