Added mobile number validation functionality
This commit is contained in:
@@ -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
|
||||
|
@@ -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'])))
|
||||
|
Reference in New Issue
Block a user