PROGROUP
CONTACT US
DRIVER TRAINING • COMPLIANCE • WORKFORCE SOLUTIONS
Have a question about training, compliance or workforce support?
Complete the form below and a member of the PROGroup team will contact you.
Send Us An Enquiry
Complete the details below.
Fields marked
*
are required.
PROGroup
Professional Driver Training, Compliance & Workforce Solutions.
document.addEventListener( 'DOMContentLoaded', function () {
const form = document.getElementById('contactForm');
const button = document.getElementById('pgSubmit');
const status = document.getElementById('pgStatus');
if (!form || !button || !status) { return; }
form.addEventListener( 'submit', async function (e) {
e.preventDefault();
/* VALIDATE FORM */
if (!form.reportValidity()) { return; }
/* SENDING STATE */
button.disabled = true;
button.textContent = 'SENDING...';
status.style.display = 'none';
status.textContent = '';
/* COLLECT FORM */
const formData = new FormData(form);
/* * This must match the PHP: * * wp_ajax_progroup_contact_form */
formData.append( 'action', 'progroup_contact_form' );
try {
/* SEND TO WORDPRESS */
const response = await fetch( '/wp-admin/admin-ajax.php', { method: 'POST', body: formData, credentials: 'same-origin' } );
/* * Get response as text first. * This makes troubleshooting easier * if WordPress returns something * other than JSON. */
const responseText = await response.text();
let result;
try {
result = JSON.parse(responseText);
} catch (jsonError) {
throw new Error( 'The website returned an unexpected response.' );
}
/* CHECK PHP RESULT */
if ( !response.ok || !result.success ) {
let errorMessage = 'Your enquiry could not be sent.';
if (result && result.data) {
if ( typeof result.data === 'string' ) {
errorMessage = result.data;
} else if ( result.data.message ) {
errorMessage = result.data.message;
}
}
throw new Error( errorMessage );
}
/* ========================= SUCCESS ========================= */
status.style.display = 'block';
status.style.background = 'rgba(40,167,69,.12)';
status.style.border = '1px solid #28a745';
status.style.color = '#7ee296';
status.textContent = '✓ Thank you. Your enquiry has been sent successfully to PROGroup.';
/* * Clear the completed form * only after PHP confirms * successful sending. */
form.reset();
} catch (error) {
/* ========================= ERROR ========================= */
status.style.display = 'block';
status.style.background = 'rgba(220,53,69,.12)';
status.style.border = '1px solid #dc3545';
status.style.color = '#ff8b96';
status.textContent = '✕ ' + ( error.message || 'Your enquiry could not be sent. Please try again.' );
}
/* RESTORE BUTTON */
button.disabled = false;
button.textContent = 'SEND ENQUIRY';
/* SHOW RESULT */
status.scrollIntoView({ behavior:'smooth', block:'nearest' });
} );
} );