Home > widget-integration > FilterValidationHelper > escapeHtml
FilterValidationHelper.escapeHtml() method
Escapes special characters in a string for safe use in HTML.
Converts characters like <, >, &, ", ' to their HTML entity equivalents.
Signature:
escapeHtml(text: string): string;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
text |
string |
The text to escape. Plain text that may contain special characters. |
Returns:
string
Escaped text safe for HTML insertion via innerHTML
Example
Safely insert user text into HTML:
const escaped = this.validationHelper.escapeHtml(userText);
element.innerHTML = `<div>${escaped}</div>`;