Phone Number Field In join form . Help.

Yeah i know how to create a new field for the join form. What i need help with is that i want a phone number field which i would create and it would only accepts numbers.

 

I have a range of numbers to accept. 

Eg. 623xxxx

 

xxxx means it can be any number. but it must begin with 623. There is a list of numbers it could begin with, if it doesn't begin with those numbers then users can't join. Please help. HOw can i do this. Its only to accept 7 numbers in total. 

 

Help me Please. 

Quote · 13 Sep 2012

New field.

Type text.

In advanced set min to 7, max to 7 and check to return (bool) preg_match('/623\d{4}/', $arg0);



https://www.deanbassett.com
Quote · 13 Sep 2012

Thanks, But its not only one set of number range.. its many,..eg:

600xxxx

601xxxx

602xxxx

604xxxx 

etc..


how can i do that  check? o.O for all of them??

Quote · 14 Sep 2012

 

but it must begin with 623.

Sorry. I saw this, and assumed it must begin with 623.

Impossable to come up with a ruleset to restrict without knowing the full allowable numberset.

But if thay are all in the 600 range, then return (bool) preg_match('/6\d{6}/', $arg0);

https://www.deanbassett.com
Quote · 14 Sep 2012

The following is pseudocode, and I know know dolphin yet enough to tell you how to implement it. But hopefully you get the idea. If the the regular expression matches a prefix it will immediatly exit, if it never matches, it never returns true, so the default return of false is called when the foreach exits.

$acceptable_prefixes = array(

"123", "234", "456",

);

$counter = 0;

foreach ($acceptable_prefixes as $key=>$value) {

 if (preg_match('/'.$value.'\d{4}/', $arg0) ) {

return "success";

}

return "fail";

}

Quote · 14 Sep 2012

i did this:

return (bool) preg_match('/610\d{4}/',''/600\d{4}/','/601\d{4}/','/602\d{4}/',

'/604\d{4}/','/605\d{4}/','/607\d{4}/','/620\d{4}/',

'/621\d{4}/','/622\d{4}/','/623\d{4}/','/624\d{4}/',

'/625\d{4}/','/626\d{4}/','/627\d{4}/','/628\d{4}/',

'/629\d{4}/','/630\d{4}/','/631\d{4}/','/632\d{4}/',

'/633\d{4}/','/634\d{4}/','/635\d{4}/','/636\d{4}/',

'/637\d{4}/',

$arg0);

 

 but it didn't work. thats the entire number set. its from greater to or equal to 600 but less than or equal to 637. 

Quote · 14 Sep 2012

Nocare. But where do i write such a code? in a  file.. or in the check thing for the field? o.O 

Quote · 14 Sep 2012

No idea, I'm searching for how to do this for my own project. Trying to avoid hardcoding it into the script

Quote · 14 Sep 2012

Then it would be this.

return (bool) preg_match('/6[0-3][0-7]\d{4}/', $arg0);

Covers 6000000 to 6379999

https://www.deanbassett.com
Quote · 14 Sep 2012

Thanks for helping "NoCare" and  • :D

Deano, it worked. :D

Quote · 14 Sep 2012
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.