SkyRanger Posted October 1, 2019 Share Posted October 1, 2019 (edited) Having a validation issue when a person enters a - in there name it is kicking it back as invalid. For axample: Mary-Ann Invalid Mary Ann Valid Tried including the - but causing myself a lot of grief. function filterkudoagent($field){ // Sanitize user name $field = filter_var(trim($field), FILTER_SANITIZE_STRING); // Validate user name if(filter_var($field, FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>"/^[a-zA-Z\s]+$/")))){ return $field; } else { return FALSE; } } Edited October 1, 2019 by SkyRanger Quote Link to comment Share on other sites More sharing options...
SkyRanger Posted October 1, 2019 Author Share Posted October 1, 2019 Figured it out. Was putting the - in the wrong spot: options"=>array("regexp"=>"/^[a-zA-Z-\s]+$/")))){ Quote Link to comment Share on other sites More sharing options...
Barand Posted October 1, 2019 Share Posted October 1, 2019 What if the name is Renée? Quote Link to comment Share on other sites More sharing options...
SkyRanger Posted October 1, 2019 Author Share Posted October 1, 2019 Then I am in trouble because it never crossed my mind until you brought it up. Quote Link to comment Share on other sites More sharing options...
SkyRanger Posted October 1, 2019 Author Share Posted October 1, 2019 (edited) Adding this should work should it not? À-ÿ regexp"=>"/^[a-zA-ZÀ-ÿ-\s]+$/ Edited October 1, 2019 by SkyRanger Quote Link to comment Share on other sites More sharing options...
Barand Posted October 1, 2019 Share Posted October 1, 2019 I don't know - regex is my Achille's heel (Well, one of them - I'm a centipede in that repect) Sorry, I only have the problem and not the solution. Quote Link to comment Share on other sites More sharing options...
SkyRanger Posted October 1, 2019 Author Share Posted October 1, 2019 (edited) lol, thanks Barand. I was able to test it and it worked. So now it is bilingual but not Multi at this time. Maybe down the road. Edited October 1, 2019 by SkyRanger Quote Link to comment Share on other sites More sharing options...
Zane Posted October 2, 2019 Share Posted October 2, 2019 You can use this regex to match internationally, even Japanese. /([\w -'\p{L}]+)/ 1 Quote Link to comment Share on other sites More sharing options...
SkyRanger Posted October 11, 2019 Author Share Posted October 11, 2019 Thanks Zane Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.