I noticed that a user entered text "πΌπππππππ" in our form when filling out their city. We would like to reject such text in our form. I tried searching for a while, but I couldn't find what type of text this is, and how can I reject it?
Looking further, encoding this text gives an output like: '%F0%9D%99%BC%F0%9D%9A%8A%F0%9D%9A%9B%F0%9D%9A%9C%F0%9D%9A%8B%F0%9D%9A%8E%F0%9D%9A%9B%F0%9D%9A%90', but it does seem like this text is utf-8 encoded.
My knowledge in this field is limited, could someone please guide if there's a way to block such text? or what type of string this is?
Appreciate the help! I will update the question so that it makes more sense once I receive an answer.
You colud try with a regex that allow only alphanumerical chars:
if (!input.match(/^\w+$/)) {
return console.log('only alphanumerical chars are allowed')
} else {
//proceed with script
}
Explanation:
^ start of the string\w any word character (A-Z, a-z, 0-9, _).$ end of the string