How to exclude html tags validation in object value?
There is a component with a text editor for filling out a form, the value of which contains html tags for formatting. That is, if the following text is entered in the field:
it will remain in this form:
description: "<p>Please note that only the <strong>first 120 characters</strong> will always be displayed when you share the event via social media. </p>"
This field is required, and if it is empty, do not let the user go further.
The problem is that if you clear all the text from the input, the html tags will remain, and the value will look like this:
description: "& lt; p & gt; & lt; br & gt; & lt; / p & gt;"
Because of this, the form considers itself complete and skips the user further.
Check not innerHTML but textContent
trim () would also be nice to call to exclude spaces.Kira Bentley
To place the code, please use CodePen or similar tool. Thanks you!