Form fields get blanked out


#1

I made a Hubspot form with several custom fields that are filled with values from the page through my own local javascript like

$("#fieldname").val(“my custom text”);

(These fields are supposed to be input type=hidden later.)
But I noticed while still in development when they are visible, as soon as I click on a regular field to edit it, all my custom field values are blanked out/go back to default.

Anyone know what I can do about this?


#2

@Paul1 HubSpot forms are built using ReactJS, so you’ll need to explicitly call the change event on the fields for them to update.


#3

Thank you very much. Adding .change() to my .val() took care of this.


#4

$("#fieldname").val(“my custom text”).change();