Insert meta-description into Yoast-SEO input-field via JavaScript

It sounds like Yoast-SEO is using some internal data structure to store the meta-description in addition to the visible div and hidden input field. This would explain why the plugin is showing an error message when you replace the content of the div and input field.

To resolve this issue, you may need to investigate the Yoast-SEO plugin’s code to determine how it is storing and validating the meta-description. It’s possible that there is a specific function or data structure that you need to use to properly update the meta-description.

Alternatively, you could try triggering the update functionality of Yoast-SEO directly rather than trying to replace the content of the div and input field. This could involve calling a specific function or triggering an event that Yoast-SEO uses to update the meta-description.

Without more specific information on how the Yoast-SEO plugin works, it’s difficult to provide a more detailed solution. If you are having trouble resolving the issue, you may want to reach out to the Yoast-SEO support team or community for assistance.