Adding Mobile phone numbers - New Zealand
Posted: Mon Apr 11, 2016 10:05 pm
Hi - I am having some problems adding New Zealand phone numbers. I can add an ordinary nine digit number - such as 031234567, but when adding mobile numbers and free phone numbers, I get problems.
Mobile numbers:
I can add 021123456, and 02112345678, but not 0211234567
Free phone numbers
I can add 080012345 and 0800123456 and 080012345678, but not 08001234567
I thought it was something to do with models/person.php, but am not sure now. It looks to me as though it should the numbers correctly. But I'm a bit rusty on these things
Also - numbers that will validate will also validate with additional characters on the end. eg 0211234567812345678910 will validate and get entered into the data base. 02112345678thisshouldbestopped will validate, but only the numerical part will get added to the data base.
This seems to stop it happening.
But still does not validate my phone number 
Mobile numbers:
I can add 021123456, and 02112345678, but not 0211234567
Free phone numbers
I can add 080012345 and 0800123456 and 080012345678, but not 08001234567
I thought it was something to do with models/person.php, but am not sure now. It looks to me as though it should the numbers correctly. But I'm a bit rusty on these things

Code: Select all
if ($this->data[$this->alias]['addr_country'] == 'New Zealand') {
$this->validate['addr_postalcode']['postal'] = array(
'rule' => array('postal', '/^[0-9]{4}/', 'nz'),
'message' => 'You must enter a valid New Zealand postal code',
);
$this->validate['home_phone']['phone']['rule'] = $this->validate['work_phone']['phone']['rule'] =
$this->validate['mobile_phone']['phone']['rule'] = $this->validate['alternate_work_phone']['phone']['rule'] =
$this->validate['alternate_mobile_phone']['phone']['rule'] = array('phone', '/^((03|04|06|07|09)\d{7})|((021|022|026|027|028|029)\d{6,8})|((0508|0800|0900)\d{5,8})$/');
}
This seems to stop it happening.
Code: Select all
$this->validate['alternate_mobile_phone']['phone']['rule'] = array('phone', '/(^(03|04|06|07|09)\d{7}$|^(021|022|026|027|028|029)\d{6,8}$|^(0508|0800|0900)\d{5,8}$)/');
