Enhance state verification in regn form
This commit is contained in:
@@ -15,6 +15,7 @@ function _booking_state_options() {
|
|||||||
$options_array['TAS'] = 'TAS';
|
$options_array['TAS'] = 'TAS';
|
||||||
$options_array['NZ'] = 'NZ';
|
$options_array['NZ'] = 'NZ';
|
||||||
$options_array['Other'] = 'Other';
|
$options_array['Other'] = 'Other';
|
||||||
|
$options_array['_blank_'] = '';
|
||||||
return $options_array;
|
return $options_array;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@@ -1160,44 +1160,57 @@ function _booking_validate($node, &$form_state) {
|
|||||||
form_set_error('booking_dob', t('Unfortunately you are too young to attend !event.',
|
form_set_error('booking_dob', t('Unfortunately you are too young to attend !event.',
|
||||||
array ('!event' => variable_get('booking_event_name','this event'))));
|
array ('!event' => variable_get('booking_event_name','this event'))));
|
||||||
}
|
}
|
||||||
|
|
||||||
//check the terms and conditions have been agreed to
|
|
||||||
if ($form_state['booking_agreement'] == 0)
|
|
||||||
form_set_error('booking_agreement', t('You must read and agree with the aims and expectations prior to submitting this form.'));
|
|
||||||
|
|
||||||
//check the medicare number for people in Australia
|
//check the medicare number for people in Australia
|
||||||
if (variable_get('booking_enable_medicare', 1) == 1 && $form_state['booking_country'] == 'Australia')
|
if (variable_get('booking_enable_medicare', 1) == 1 && $form_state['booking_country'] == 'Australia')
|
||||||
{
|
{
|
||||||
//proper validation routine at http://dyball.wordpress.com/2007/12/05/validation-of-medicare-numbers/
|
//proper validation routine at http://dyball.wordpress.com/2007/12/05/validation-of-medicare-numbers/
|
||||||
if (! _valid_medicare_number($form_state['booking_medicare']))
|
if ( (variable_get('booking_enforce_medicare_verification', 1) == 1) && (! _valid_medicare_number($form_state['booking_medicare'])) )
|
||||||
{
|
{
|
||||||
if (variable_get('booking_enforce_medicare_verification', 1) == 1) {
|
form_set_error(
|
||||||
form_set_error('booking_medicare',
|
'booking_medicare',
|
||||||
t('You have entered an invalid medicare number. Please check your medicare card and re-enter the number. ' .
|
t('You have entered an invalid medicare number. Please check your medicare card and re-enter the number. If you believe this to be incorrect, please !contact.',
|
||||||
'If you believe this to be incorrect, please !contact.',
|
array('!contact' => l('send us an email', 'mailto:' . variable_get('booking_contact_email') . '?subject=Invalid Medicare Number'))
|
||||||
array('!contact' => l('send us an email', 'mailto:' . variable_get('booking_contact_email') .
|
)
|
||||||
'?subject=Invalid Medicare Number'))
|
);
|
||||||
)
|
}
|
||||||
);
|
elseif ( (variable_get('booking_enforce_medicare_verification', 1) == 0) && (! _valid_medicare_number($form_state['booking_medicare'])) )
|
||||||
}
|
{
|
||||||
else {
|
drupal_set_message(
|
||||||
drupal_set_message(
|
t('You have entered an invalid medicare number. Please ensure you check your medicare card and send us the correct information via !contact.',
|
||||||
t('You have entered an invalid medicare number. Please ensure you check your medicare card' .
|
array('!contact' => l('email', 'mailto:' . variable_get('booking_contact_email') . '?subject=Invalid Medicare Number'))
|
||||||
' and send us the correct information via !contact.',
|
),
|
||||||
array('!contact' => l('email', 'mailto:' . variable_get('booking_contact_email') .
|
'error', FALSE
|
||||||
'?subject=Invalid Medicare Number'))
|
);
|
||||||
), 'error', FALSE
|
}
|
||||||
);
|
}
|
||||||
}
|
|
||||||
}
|
//verify state information with the new few checks
|
||||||
|
|
||||||
|
//make sure state field is not blank
|
||||||
|
if ($form_state['booking_state'] == '_blank_' )
|
||||||
|
{
|
||||||
|
form_set_error('booking_state',
|
||||||
|
t('You must enter your State in the address section of the Contact details. ' .
|
||||||
|
'Please choose a state of Other and specify N/A if your country does not have states, or choose NZ if you reside in New Zealand.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
//verify international address has updated the state field
|
//verify international address has updated the state field
|
||||||
if ((strcasecmp($form_state['booking_country'], 'Australia') !== 0) && (strcasecmp($form_state['booking_state'], 'Other') !== 0) && (strcasecmp($form_state['booking_state'], 'NZ') !== 0))
|
if ((strcasecmp($form_state['booking_country'], 'New Zealand') == 0) && (strcasecmp($form_state['booking_state'], 'NZ') !== 0))
|
||||||
{
|
{
|
||||||
form_set_error('booking_state', t('You must enter your State in the address section of the Contact details. Please choose a state of Other and specify N/A if your country does not have states.'));
|
form_set_error('booking_state',
|
||||||
|
t('You have indicated you reside in New Zealand. Please select NZ as your state.'));
|
||||||
}
|
}
|
||||||
|
elseif ((strcasecmp($form_state['booking_country'], 'Australia') !== 0) && (strcasecmp($form_state['booking_state'], 'Other') !== 0) && (strcasecmp($form_state['booking_state'], 'NZ') !== 0))
|
||||||
|
{
|
||||||
|
form_set_error('booking_state',
|
||||||
|
t('You must enter your State in the address section of the Contact details. Please choose a state of Other and specify N/A if your country does not have states.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
//verify that a state has been entered if "Other" was selected
|
||||||
|
if (($form_state['booking_state'] == 'Other' ) && ($form_state['booking_other_state'] == ''))
|
||||||
|
form_set_error('booking_other_state', t('You must enter your State in the address section of the Contact details. Please put N/A if your country does not have states.'));
|
||||||
|
|
||||||
//verify passport number
|
//verify passport number
|
||||||
if (variable_get('booking_enable_passport', 0) == 1 && $form_state['booking_country'] == 'Australia')
|
if (variable_get('booking_enable_passport', 0) == 1 && $form_state['booking_country'] == 'Australia')
|
||||||
{
|
{
|
||||||
@@ -1223,14 +1236,13 @@ function _booking_validate($node, &$form_state) {
|
|||||||
if (($form_state['booking_mobile'] != '' ) && ($form_state['booking_country'] == 'Australia') && (!_valid_australian_mobile_number($form_state['booking_mobile'])))
|
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.'));
|
form_set_error('booking_mobile', t('You have entered an invalid mobile phone number.'));
|
||||||
|
|
||||||
|
|
||||||
//verify guardian phone number(s)
|
//verify guardian phone number(s)
|
||||||
if (($form_state['booking_guardian_phone'] != '' ) && (!_valid_phone_number($form_state['booking_guardian_phone'])))
|
if (($form_state['booking_guardian_phone'] != '' ) && (!_valid_phone_number($form_state['booking_guardian_phone'])))
|
||||||
form_set_error('booking_guardian_phone', t('You have entered an contact phone number for your emergency contact.'));
|
form_set_error('booking_guardian_phone', t('You have entered an contact phone number for your emergency contact.'));
|
||||||
|
|
||||||
//verify that a state has been entered if "Other" was selected
|
//check the terms and conditions have been agreed to. Do this one last so it stands out more
|
||||||
if (($form_state['booking_state'] == 'Other' ) && ($form_state['booking_other_state'] == ''))
|
if ($form_state['booking_agreement'] == 0)
|
||||||
form_set_error('booking_other_state', t('You must enter your State in the address section of the Contact details. Please put N/A if your country does not have states.'));
|
form_set_error('booking_agreement', t('You must read and agree with the aims and expectations prior to submitting this form.'));
|
||||||
|
|
||||||
//if there are any errors then log the data the user entered so we can check it later
|
//if there are any errors then log the data the user entered so we can check it later
|
||||||
if (form_get_errors()) {
|
if (form_get_errors()) {
|
||||||
|
Reference in New Issue
Block a user