Interview Story Diagnostic
Answer each question honestly. All questions are required.
Hello, World!
/**
* FORM PAGE SCRIPT (form-handler.js)
* Place this in a Code Block AFTER your form on the Form Page
* NOW SUPPORTS: lowercase, UPPERCASE, or Title Case field names
*/
document.addEventListener('DOMContentLoaded', function() {
const form = document.querySelector('form'); // Squarespace form
if (!form) {
console.error('Form not found on page');
return;
}
// Prevent default Squarespace form submission
form.addEventListener('submit', function(e) {
e.preventDefault();
e.stopPropagation();
// Collect form data - will store in lowercase for consistency
const formData = {
email: '',
power: '',
role: '',
structure: '',
persuasion: '',
time: '',
scope: '',
energy: ''
};
// Helper function to find field by name (case-insensitive)
function findFieldValue(fieldName) {
// Try exact match first
let field = form.querySelector('[name="' + fieldName + '"]');
if (field) return field;
// Try lowercase
field = form.querySelector('[name="' + fieldName.toLowerCase() + '"]');
if (field) return field;
// Try uppercase
field = form.querySelector('[name="' + fieldName.toUpperCase() + '"]');
if (field) return field;
// Try title case
const titleCase = fieldName.charAt(0).toUpperCase() + fieldName.slice(1).toLowerCase();
field = form.querySelector('[name="' + titleCase + '"]');
if (field) return field;
return null;
}
let hasErrors = false;
const errors = [];
// Get email field (handle type="email" or name variations)
let emailInput = form.querySelector('input[type="email"]');
if (!emailInput) {
emailInput = findFieldValue('email');
}
if (emailInput) {
formData.email = emailInput.value.trim();
if (!formData.email) {
errors.push('Email is required');
hasErrors = true;
}
} else {
errors.push('Email field not found');
hasErrors = true;
}
// Get all axis fields (radio buttons or dropdowns)
const axisFields = ['power', 'role', 'structure', 'persuasion', 'time', 'scope', 'energy'];
axisFields.forEach(function(axis) {
let value = null;
// Try to find radio buttons (case-insensitive)
const variations = [
axis,
axis.toLowerCase(),
axis.toUpperCase(),
axis.charAt(0).toUpperCase() + axis.slice(1).toLowerCase()
];
for (let variant of variations) {
const radioGroup = form.querySelectorAll('input[name="' + variant + '"]:checked');
if (radioGroup.length > 0) {
value = radioGroup[0].value;
break;
}
}
// If no radio found, try select dropdown
if (value === null) {
for (let variant of variations) {
const selectField = form.querySelector('select[name="' + variant + '"]');
if (selectField && selectField.value) {
value = selectField.value;
break;
}
}
}
if (value === null) {
errors.push(axis.charAt(0).toUpperCase() + axis.slice(1) + ' selection is required');
hasErrors = true;
} else {
formData[axis] = value;
}
});
// Validate all axes have values 1-5
if (!hasErrors) {
axisFields.forEach(function(axis) {
const val = parseInt(formData[axis]);
if (isNaN(val) || val < 1 || val > 5) {
errors.push(axis.charAt(0).toUpperCase() + axis.slice(1) + ' must be between 1 and 5');
hasErrors = true;
}
});
}
// If errors, show them
if (hasErrors) {
alert('Please fix the following errors:\n\n' + errors.join('\n'));
return;
}
// Store data in sessionStorage
try {
sessionStorage.setItem('diagnosticData', JSON.stringify(formData));
// Redirect to results page
// CHANGE THIS URL to your actual Results page URL
window.location.href = '/zebu-interview-diagnostic-thank-you';
} catch (err) {
alert('Error saving data. Please try again.');
console.error('Storage error:', err);
}
});
});