Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 136 additions & 1 deletion modules/careers/CareersUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,7 @@ private function _makeApplyValidator($template)
{
$validator = '';

// First name is always required if the field is present in the template.
if (strpos($template['Content'], '<input-firstName>') !== false || strpos($template['Content'], '<input-firstName req>') !== false)
{
$validator .= '
Expand All @@ -991,6 +992,7 @@ private function _makeApplyValidator($template)
}';
}

// Last name is always required if the field is present in the template.
if (strpos($template['Content'], '<input-lastName>') !== false || strpos($template['Content'], '<input-lastName req>') !== false)
{
$validator .= '
Expand All @@ -1002,6 +1004,7 @@ private function _makeApplyValidator($template)
}';
}

// Email confirmation must match the primary email if the field is present.
if (strpos($template['Content'], '<input-emailconfirm>') !== false || strpos($template['Content'], '<input-emailconfirm req>') !== false)
{
$validator .= '
Expand All @@ -1013,6 +1016,7 @@ private function _makeApplyValidator($template)
}';
}

// Primary email must be present and must look somewhat valid.
if (strpos($template['Content'], '<input-email>') !== false || strpos($template['Content'], '<input-email req>') !== false)
{
$validator .= '
Expand All @@ -1031,6 +1035,11 @@ private function _makeApplyValidator($template)
}';
}

/*
* Optional fields that can be made required by using the "req" marker
* in the template, for example <input-phone-cell req>.
*/

if (strpos($template['Content'], '<input-address req>') !== false)
{
$validator .= '
Expand All @@ -1047,7 +1056,7 @@ private function _makeApplyValidator($template)
$validator .= '
if (document.getElementById(\'address2\').value == \'\')
{
alert(\'Please enter an address.\');
alert(\'Please enter address line 2.\');
document.getElementById(\'address2\').focus();
return false;
}';
Expand Down Expand Up @@ -1097,6 +1106,84 @@ private function _makeApplyValidator($template)
}';
}

if (strpos($template['Content'], '<input-phone-cell req>') !== false)
{
$validator .= '
if (document.getElementById(\'phoneCell\').value == \'\')
{
alert(\'Please enter a mobile phone number.\');
document.getElementById(\'phoneCell\').focus();
return false;
}';
}

if (strpos($template['Content'], '<input-phone-home req>') !== false)
{
$validator .= '
if (document.getElementById(\'phoneHome\').value == \'\')
{
alert(\'Please enter a home phone number.\');
document.getElementById(\'phoneHome\').focus();
return false;
}';
}

if (strpos($template['Content'], '<input-best-time-to-call req>') !== false ||
strpos($template['Content'], '<input-bestTimeToCall req>') !== false)
{
$validator .= '
if (document.getElementById(\'bestTimeToCall\').value == \'\')
{
alert(\'Please enter the best time to call.\');
document.getElementById(\'bestTimeToCall\').focus();
return false;
}';
}

if (strpos($template['Content'], '<input-email2 req>') !== false)
{
$validator .= '
if (document.getElementById(\'email2\').value == \'\')
{
alert(\'Please enter an E-Mail address.\');
document.getElementById(\'email2\').focus();
return false;
}';
}

if (strpos($template['Content'], '<input-source req>') !== false)
{
$validator .= '
if (document.getElementById(\'source\').value == \'\')
{
alert(\'Please enter a source.\');
document.getElementById(\'source\').focus();
return false;
}';
}

if (strpos($template['Content'], '<input-employer req>') !== false)
{
$validator .= '
if (document.getElementById(\'employer\').value == \'\')
{
alert(\'Please enter your current employer.\');
document.getElementById(\'employer\').focus();
return false;
}';
}

if (strpos($template['Content'], '<input-resumeUpload req>') !== false)
{
$validator .= '
if (document.getElementById(\'resume\').value == \'\')
{
alert(\'Please upload your resume.\');
document.getElementById(\'resume\').focus();
return false;
}';
}

if (strpos($template['Content'], '<input-keySkills req>') !== false)
{
$validator .= '
Expand All @@ -1119,6 +1206,54 @@ private function _makeApplyValidator($template)
}';
}

/*
* EEO fields (if enabled and placed in the template).
*/

if (strpos($template['Content'], '<input-eeo-gender req>') !== false)
{
$validator .= '
if (document.getElementById(\'eeogender\').value == \'\')
{
alert(\'Please select your gender.\');
document.getElementById(\'eeogender\').focus();
return false;
}';
}

if (strpos($template['Content'], '<input-eeo-race req>') !== false)
{
$validator .= '
if (document.getElementById(\'eeorace\').value == \'\')
{
alert(\'Please select your race.\');
document.getElementById(\'eeorace\').focus();
return false;
}';
}

if (strpos($template['Content'], '<input-eeo-veteran req>') !== false)
{
$validator .= '
if (document.getElementById(\'eeoveteran\').value == \'\')
{
alert(\'Please select your veteran status.\');
document.getElementById(\'eeoveteran\').focus();
return false;
}';
}

if (strpos($template['Content'], '<input-eeo-disability req>') !== false)
{
$validator .= '
if (document.getElementById(\'eeodisability\').value == \'\')
{
alert(\'Please select your disability status.\');
document.getElementById(\'eeodisability\').focus();
return false;
}';
}

$validator = '<script type="text/javascript">function applyValidate() {'
. $validator . ' return true; }' . "\n" . '</script>';

Expand Down
Loading