Form on external site not able to manually update input values

Hi,

Using a form embedded in an external HTML page. I need to copy a form value from one element to another and i am using the events for onFormReady. Example code below. If i step through the form then it works but after onFormReady finishes the value defaults back to being blank. I understand the .change() is suppose to update this but no luck for me.

(The email is being copied to a custom object)

Any ideas?

Kindest
Paul

hbspt.forms.create({

region: “na1”,

portalId: “XXX”,

formId: “XXX”,

onFormReady: function($form) {

var em = $(‘input[name=“email”]’).val();

$(‘input[name=“2-13702406/email_address”]’).val(em).change();

}

});

Hey @PCurtis my JS is a bit rusty these days, but just speculating, could this update to blank be caused by the email validation script on the email field? I know HS forms triggers the validation on the email field as the user is typing in it so I wonder if that’s causing a conflict with your script pulling the value.
Out of curiosity, would “onFormSubmit” work for this usecase? Might help avoid any conflicts as the form is updating.

Yes, i think the onFormSubmit is a better event. The FormReady i think may fire before something which updates the form…
Going to mark this as the solution