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.

3
  • 1
    Does this help? Commented Feb 3, 2022 at 10:40
  • ^ Possible duplicate How to remove emoji code using javascript? Commented Feb 3, 2022 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. :) Commented Feb 3, 2022 at 12:31

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.