diff --git a/booking.helper.inc b/booking.helper.inc index 75eef5a..2aa9e88 100644 --- a/booking.helper.inc +++ b/booking.helper.inc @@ -101,6 +101,18 @@ function _valid_phone_number($input) */ } +function _valid_australian_mobile_number($input) +{ + if (preg_match('/^\s*(?:\+61|61|0061|0)(\d{3})\s*(\d{3})\s*(\d{3})\s*$/', $input, $matches)) + { + watchdog('booking', 'Australian Mobile Number "!passnum" validates since it passed our regexp', + array('!passnum' => $input)); + return TRUE; + } + else + return FALSE; +} + /** * Helper function to check whether the number of registrations for the current event have reached their defined maximum size diff --git a/booking.regn_form.inc b/booking.regn_form.inc index da6b5e5..9eb66fc 100644 --- a/booking.regn_form.inc +++ b/booking.regn_form.inc @@ -1177,8 +1177,13 @@ function _booking_validate($node, &$form_state) { form_set_error('booking_mobile', t('You must enter at least one phone number, either a mobile phone or a home phone number.')); if (($form_state['booking_phone'] != '' ) && (!_valid_phone_number($form_state['booking_phone']))) form_set_error('booking_phone', t('You have entered an invalid home phone number.')); - if (($form_state['booking_mobile'] != '' ) && (!_valid_phone_number($form_state['booking_mobile']))) - form_set_error('booking_mobile', t('You have entered an invalid mobile phone number.')); + if (($form_state['booking_mobile'] != '' ) && (!_valid_phone_number($form_state['booking_mobile']))) + form_set_error('booking_mobile', t('You have entered an invalid mobile phone number.')); + + //verify an australian mobile number is entered correctly if applicable + if (($form_state['booking_mobile'] != '' ) && ($form_state['booking_country'] == 'Australia') && (!_valid_australian_mobile_number($form_state['booking_mobile']))) + form_set_error('booking_mobile', t('You have entered an invalid mobile phone number.')); + //verify guardian phone number(s) if (($form_state['booking_guardian_phone'] != '' ) && (!_valid_phone_number($form_state['booking_guardian_phone'])))