Fill a Long Text Field Form using JavaScript

I’ve found textarea elements that correspond to [Long Text] fields do not seem to behave the same way as input elements that correspond to [Text] fields when populating forms via JavaScript.

I used this post as reference but could not replicate the .val() assignment in textarea fields.

Run basic math in real time on a form using JavaScript

Upon submission, the form does not detect any content in the textarea field until said field is modified manually, not programmatically, even if no changes are made to the content itself. (Eg: adding a single character and then deleting it, does enable submission).

Is there a proper way to populate textarea fields programmatically without forcing the user to modify the [Long Text] form field manually?

Can you try adding “.change()” after “.val()”

1 Like

Thanks Moe! Your suggestion did point me in the right direction:

Textarea and input ‘on change’ events trigger when the form fields lose focus (ie: the user clicks or tabs away, be it another field or button), not immediately when the user inputs a value. While the form field value will change on screen, the change will not commit until focus is set elsewhere. Read more :arrow_upper_right:.

The value will be taken into account so long as the field is ‘unfocused’ before submission, be it manually or programatically. This applies to both input fields and textarea fields.