[SOLVED] Validation of characters from other languages

6 years 9 months ago #295007 by rbuelund
Replied by rbuelund on topic Validation of characters from other languages
But how do I use the PHP REGEXP and not the java - can i deactivate the browser side validation and only validate on form submit ?

Please Log in to join the conversation.

6 years 9 months ago #295008 by krileon
Replied by krileon on topic Validation of characters from other languages
There's no parameter to turn off browser side validation. Best I can suggest is to use CB Code Field and doing your REGEXP validation there as that will work for browser side validation since the browser side validation is just an HTTP request instead of doing the REGEXP directly in the browser. CB Code Field lets you use custom PHP to validate any field you like.


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 #295010 by rbuelund
Replied by rbuelund on topic Validation of characters from other languages
Ok - i have tried this code in the Code field integration:
if (preg_match("/^((\b[\p{L}]{2,40}\b)\s*){2,}$/", [value])) {
    return true;
} else {
    return false;
}

But if i enter the words: "uyt kjh" in the field and hit submit, then i get the error:


Parse error: syntax error, unexpected 'kjh' (T_STRING) in /home/xxxxxx/www/components/com_comprofiler/plugin/user/plug_cbcodefield/cbcodefield.php(92) : runtime-created function on line 1

Fatal error: Function name must be a string in /home/xxxxxx/www/components/com_comprofiler/plugin/user/plug_cbcodefield/cbcodefield.php on line 93

Please Log in to join the conversation.

6 years 9 months ago #295021 by krileon
Replied by krileon on topic Validation of characters from other languages
You need to treat all substitutions as strings. So in your code change [value] to '[value]' and should work fine. You can also shorten it to just the below.

return preg_match( "/^((\b[\p{L}]{2,40}\b)\s*){2,}$/", '[value]' );


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 #295025 by rbuelund
Replied by rbuelund on topic Validation of characters from other languages
Well that line still only accepts english characters no danish - they do not get validated correctly ??

Please Log in to join the conversation.

6 years 9 months ago - 6 years 9 months ago #295026 by rbuelund
Replied by rbuelund on topic Validation of characters from other languages
Ahhhaaa got it:
return preg_match('/^((\b[\p{L}]{2,40}\b)\s*){2,}$/u', '[value]');

One needs to add the 'u' at the end to select unicode mode for php regexp ! - Sorry for the trouble!
The following user(s) said Thank You: krileon

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 1.378 seconds

Facebook Twitter LinkedIn