Skip to content
Back To Top
document.addEventListener('DOMContentLoaded', function () {
const names = ['skills-qualities', 'community-challenges', 'community-involvement', 'academy-goals'];
const fields = names.map(name => document.querySelector('.eee-cf7-form textarea[name="' + name + '"]')).filter(Boolean);
if (fields.length !== 4) return;
const count = value => { const text = value.trim(); return text ? text.split(/\s+/u).length : 0; };
fields.forEach(field => {
const status = document.createElement('small');
status.setAttribute('aria-live', 'polite');
status.style.display = 'block';
field.insertAdjacentElement('afterend', status);
const update = () => {
const total = count(field.value);
const over = total > 99;
status.textContent = total + ' / 99 words' + (over ? ' — please shorten this answer.' : '');
status.style.color = over ? '#a00' : '';
field.setCustomValidity(over ? 'Please use fewer than 100 words for this answer.' : '');
};
field.addEventListener('input', update);
update();
});
document.addEventListener('submit', function (event) {
if (!fields[0].form || event.target !== fields[0].form) return;
const invalid = fields.find(field => count(field.value) > 99);
if (invalid) { event.preventDefault(); event.stopImmediatePropagation(); invalid.reportValidity(); invalid.focus(); }
}, true);
});