2021 Salary Guide
.invalid-feedback’); if(node && node.name === ‘All’ && node.checked === false) { checkedCount = 0; } if(checkedCount) { checkboxes.each(function() { jQuery(this).removeAttr(‘required’); jQuery(this).attr(‘aria-required’, false); jQuery(this).attr(‘aria-invalid’, false); jQuery(this).attr(‘aria-describedby’, ”); invalidFeedback.hide(); jQuery(‘#submitBtn’).prop(“disabled”,false) }); } else { checkboxes.each(function() { jQuery(this).attr(‘required’,”); jQuery(this).attr(‘aria-required’, true); jQuery(this).attr(‘aria-invalid’, true); jQuery(this).attr(‘aria-describedby’, jQuery(‘#lobType > .invalid-feedback’).attr(‘id’)); invalidFeedback.show(); }); } } function handleRadioAriaAndError() { let radios = jQuery(‘#contactType input’); let isValid = radios[0].validity.valid; if (isValid) { radios.each(function() { jQuery(this).attr(‘aria-invalid’, false); jQuery(this).attr(‘aria-describedby’, ”); }); jQuery(‘#userTypeErrorMessage’).hide(); jQuery(‘#submitBtn’).prop(“disabled”,false) } else { radios.each(function() { jQuery(this).attr(‘aria-invalid’, true); jQuery(this).attr(‘aria-describedby’, jQuery(‘#contactType .invalid-feedback’).attr(‘id’)); }); jQuery(‘#userTypeErrorMessage’).show(); } } function checkboxBehavior() { // LOB Checkboxes behavior let lobs = jQuery(‘.form-check-input[type=checkbox]:not(#All)’); jQuery(“#All”).change(function () { if (this.checked) { lobs.each(function () { this.checked = true; }) } else { lobs.each(function () { this.checked = false; }) } handleCheckboxAriaAndError(this); }); lobs.click(function () { if (jQuery(this).is(“:checked”)) { let isAllChecked = 0; lobs.each(function () { if (!this.checked) isAllChecked = 1; }) if (isAllChecked == 0) { jQuery(“#All”).prop(“checked”, true); } } else { jQuery(“#All”).prop(“checked”, false); } handleCheckboxAriaAndError(this); }); } jQuery(document).ready(function () { jQuery(‘#formBody input[type=text], #formBody input[type=email]’).on(‘focusout’, handleTextAriaAndError); jQuery(‘.form-check-input[type=checkbox]’).on(‘focusout’, function() { handleCheckboxAriaAndError(this); }); jQuery(‘.form-check-input[type=radio]’).on(‘focusout’, handleRadioAriaAndError); checkboxBehavior(); // Radio options let radios = jQuery(‘#contactType input’).click(() => { jQuery(‘#contactType > .invalid-feedback’).hide() }) // grab url params function gup(name, url) { name = name.replace(/[[]/, “\[“).replace(/[]]/, “\]”); var regexS = “[\?&]” + name + “=([^&#]*)”; var regex = new RegExp(regexS, ‘i’); if (url == null) url = window.location.href; var results = regex.exec(url); if (results == null) return “”; else return unescape(results[1]); } var windowURL = window.location.href; jQuery(‘input[name=”leadUrl”]’).val(windowURL); // Populate hidden fields using gup() jQuery(‘input[name=”utmSource”]’).val(gup(‘utm_source’).replace(/+/g, ‘ ‘)); jQuery(‘input[name=”utmContent”]’).val(gup(‘utm_content’).replace(/+/g, ‘ ‘)); jQuery(‘input[name=”utmMedium”]’).val(gup(‘utm_medium’).replace(/+/g, ‘ ‘)); jQuery(‘input[name=”utmCampaign”]’).val(gup(‘utm_campaign’).replace(/+/g, ‘ ‘)); jQuery(‘input[name=”utmTerm”]’).val(gup(‘utm_term’).replace(/+/g, ‘ ‘)); jQuery(‘input[name=”SF_Contact_ID”]’).val(gup(‘i’).replace(/+/g, ‘ ‘)); }); // end ready // Submit function subForm() { // Validation let inputs = jQuery(‘#formBody input’).not(‘[type=hidden]’) for(let input of inputs){ if(input.validity.valid === false) { jQuery(‘.needs-validation’).addClass(“was-validated”); jQuery(input).focus(); handleCheckboxAriaAndError(); handleRadioAriaAndError(); jQuery(‘#submitBtn’).prop(“disabled”,true) return; } } jQuery(‘#submitBtn’).prop(“disabled”,true).text(‘Loading…’); // Redirect to the dedicated confirmation page function confirmationPages() { if(jQuery(‘[type=radio]:checked’).val() === ‘Candidate’) window.location.href = jQuery(‘#confirmUrlCA’).val(); else window.location.href = jQuery(‘#confirmUrlCL’).val(); } let getUserType = () => jQuery(‘#contactType input:checked’).val(); let getSelectedLobs = () => jQuery(‘#lobType input:checked’).map(function() { return jQuery(this).val(); }).toArray().join(); let getCurrentLob = () => jQuery(‘#RHFA’).val() || jQuery(‘#RHT’).val() || jQuery(‘#RHL’).val() || jQuery(‘#RHOT’).val() || jQuery(‘#TCG’).val(); let getLob = () => jQuery(‘#lobType’).length ? getSelectedLobs() : getCurrentLob(); // dataLayer push to trigger the GA event dataLayer.push({ ‘event’: “SalaryCenterEventTracker”, ‘form_lob’: getLob(), ‘user_type’: getUserType(), ‘event_action’: “submit form”, ‘event_category’: “salary center”, ‘event_label’: “salary guide” }); if (typeof utag != “undefined”) { // utag link push to trigger the Tealium event utag.link({ ‘tealium_event’: ‘SalaryCenterEventTracker’, ‘form_lob’: getLob(), ‘user_type’: getUserType(), ‘event_action’: “submit form”, ‘event_category’: “salary center”, ‘event_label’: “salary guide” }); } setTimeout(function () { // ajax request jQuery.ajax({ url: ‘/ajax/marketing-cloud/form-submit’, type: ‘post’, data: jQuery(‘#formBody’).serialize(), dataType: “json”, format: “json”, success: function () { console.log(‘the form is submitted’); confirmationPages(); } }); }, 50); }; //–> ]]>