HS pre-filled required input value returns required validation error

I have a required email field in a HS form. And I pre-fill it with jquery. In the form, I can see the pre-filled value. But when I click the submit button, it returns “Please complete this required field.” even though the value is set. Can someone suggest a solution for this, please? Highly appreciate your support.

This is how I set the value

$(“input[name=‘email’]”).val(‘sample@mail.com’).change();

Hey, @dmadusanka :waving_hand: Welcome to our community! Thanks for your question. Did you get this worked out?

Have you already tried triggering a form validation event after setting the value? This can be done by calling the `form.trigger(“submit”)` method, where `form` is the jQuery selector for your form. To try to trigger the form validation to re-evaluate the field value?

Best,

Jaycee

Thank you @Jaycee_Lewis for your support. I found a solution. I dispatch the change event using “emailInput.dispatchEvent(new Event(‘change’));”. This cord works. But there is another issue. I need to disable this email input so that the user cannot change the email. When I do it, this will not work again. For now, I just remove the disabled attribute from this email input.