Regular expressions to allow UTF characters through Jquery

Author - Parminder Kaur
29.08.2017
|
0 Comments
|

Regular expressions provide a powerful way of adding validations to the web forms.

To allow UTF encoded characters (Letters) either UTF -8 or UTF -16 like Á á É é Í ÑÓ ¿ € ₧ å ∫ ç ∂´ƒ ©˙ ∆˚ ¬µ ˜ø π œ ® ß † ¨√ ∑ ≈ ¥ Ω ¡™ £ ¢¡™£¢∞§ ¶

Use Regex expression \p{L}

Here L stands for ‘Letter’ from any language. It includes all the utf encoded characters from all languages.

For example:

var regex =/^([\p{L}])+$/;
regex.test("Веб-решения"); // true
regex.test(“网络解决方案”); // true
regex.test(ویب مسائل کے حلة"); // true

If we want to allow only math symbols, currency signs, box-drawing characters, etc. Then use regex expression \p{S}

For Example:

var regex = x =/^([\p{S}])+$/;
regex.test(“√ ∑ø π£€” ); //true;
Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at dev@webners.com for your Insurance, eLearning and Salesforce applications.

Leave a Reply

Your email address will not be published. Required fields are marked *

Send your message