-1

Probably this is a known problem and there is a specific best practice.

I have to fill a text field value with received text from backend.

I this text contains some 'special characters' (for example " <) I have some issued during the rendering of the page.

How can I solve this?

Can I solve this issue front-end side? I can use only javascript front-end side. I not use PHP;

I use this html code:

<input class="myclass" value="<%= text_from-backend %>" placeholder="My Placeholder"/>
Safari
  • 11,437
  • 24
  • 91
  • 191
  • This is impossible to answer unless you specify what the "some issues" are that you have and what templating system that is. A [mcve] please. – JJJ Jun 21 '19 at 14:58
  • probably what you are looking for are html entities like `>` which, if you put it into your html, will be rendered as `>`, but the question is not specific indeed – YakovL Jun 21 '19 at 18:40

1 Answers1

-3

You can replace special characters in PHP:

<input class="myclass" value="preg_replace('/[^ a-z\d]/ui','','<%= text_from-backend %>');" placeholder="My Placeholder"/>
Ru Chern Chong
  • 3,692
  • 13
  • 33
  • 43