[SOLVED] Validation of characters from other languages

6 years 10 months ago - 6 years 9 months ago #294979 by rbuelund
It would be very nice if the validation rules for a text input field also could include characters from other languages - eg from danish æ,ø,å - I have made a custom regexp for two words, but I cannot get it to accept æ ø and å:
/^((\b[a-zA-Z]{2,40}\b)\s*){2,}$/

Please Log in to join the conversation.

6 years 9 months ago #294991 by krileon
Replied by krileon on topic Validation of characters from other languages
It's just REGEXP ran through PHP (and JS if using browser validation) REGEXP functions. See the below regarding unicode in REGEXP. We have no specific limitation in place preventing this. The limitation is with PHP/JS/REGEXP.

www.regular-expressions.info/unicode.html


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

6 years 9 months ago #294992 by rbuelund
Replied by rbuelund on topic Validation of characters from other languages
But I also ment your default vallidation suggestions in the validation settings - they also only allow english characters. Would be nice to let them allow alpha numeric from all languages ;-)

Please Log in to join the conversation.

6 years 9 months ago #294996 by krileon
Replied by krileon on topic Validation of characters from other languages
Don't understand what you mean. Validation suggestions? You mean the validation errors? If you mean the validation errors they are language strings so you can translate them to whatever you like. If you mean the dropdown that provides a few regexp examples I don't see a reason to extend it any further as we provide a means of providing your own regexp.

To give you an example in your current regexp you're using [a-zA-Z], which is literally matching the characters a-z in their lower and uppercase forms. You can simplify this with a word character match using just \w, which will match unicode letters, numbers, and underscores. If you truly just want a-z, but also want it unicode then you probably need to use [\p{L}].


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

6 years 9 months ago - 6 years 9 months ago #295002 by rbuelund
Replied by rbuelund on topic Validation of characters from other languages
But this code works for two words (longer than 2 chars) with a-z:
/^((\b[a-zA-Z]{2,40}\b)\s*){2,}$/

But as you suggested - this code does not work for two words (longer than 2 chars) with unicode characters:
/^((\b[\p{L}]{2,40}\b)\s*){2,}$/

The above only accepts for example: ppp LLL and no other characters - so it looks like \p{L} - does not work at all

??

Please Log in to join the conversation.

6 years 9 months ago #295006 by krileon
Replied by krileon on topic Validation of characters from other languages
The REGEXP to match unicode letters is [\p{L}]. This works in PHP REGEXP. It will not work in JS. This means it will not work in browser side validation. For JS unicode I believe you have to specify every unicode character you want to match using it's hexadecimal value. Again, none of this is a limitation of CB. You are only limited by what PHP and JS support.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.207 seconds

Facebook Twitter LinkedIn