0

I am trying to validate an input text field to not allow icons to be pasted into it. For example, having this:

Hello

When I tried debugging, I noticed Javascript interpreted the icons in a Unicode format. So I tried using regex to only allow letters and exclude Unicodes.

Another problem arises, that is, to allow special characters of other languages (these are also converted to a range of Unicodes by Javascript.

To solve this I had to keep adding Unicode range for each language in the regex (this is a whole lot).

I need a better solution to help remove or not allow pasting icons like above to the input text field. I will appreciate your help with this. Thanks.

Techbola
  • 21
  • 1
  • 5
  • 1
    Does [this](https://stackoverflow.com/questions/10992921/how-to-remove-emoji-code-using-javascript) help? – Esszed Feb 03 '22 at 10:40
  • ^ Possible duplicate [How to remove emoji code using javascript?](https://stackoverflow.com/questions/10992921/how-to-remove-emoji-code-using-javascript) – Liftoff Feb 03 '22 at 10:42
  • @Esszed thanks. The link really helped. I fixed it by checking if the input string contained emoji icons then replacing them with empty space and trimmed. :) – Techbola Feb 03 '22 at 12:31

0 Answers0