Select a Service
Accounting System Implementation
Bookkeeping & Accounting Services
Advisory
Fractional CFO Services
Tax Services
Audit
Special Project/Other Inquires
Transaction Advisory Services
Free Consultationalpinemar2026-04-16T06:59:32-04:00
document.addEventListener("DOMContentLoaded", function () {
const form = document.getElementById("airtable-form");
const statusEl = document.getElementById("form-status");
if (!form) return;
const cleanValue = (val) =>
String(val || "")
.trim()
.replace(/^"+|"+$/g, "");
form.addEventListener("submit", async function (e) {
e.preventDefault();
// ✅ Turnstile token check
const turnstileToken = document.querySelector('[name="cf-turnstile-response"]')?.value;
if (!turnstileToken) {
if (statusEl) statusEl.textContent = "Please complete the CAPTCHA verification.";
alert("Please complete the CAPTCHA verification.");
return;
}
const submitBtn = form.querySelector('button[type="submit"]');
if (submitBtn) submitBtn.disabled = true;
if (statusEl) statusEl.textContent = "Submitting...";
const payload = new URLSearchParams({
action: "submit_airtable_form",
first_name: cleanValue(document.getElementById("first_name").value),
last_name: cleanValue(document.getElementById("last_name").value),
email: cleanValue(document.getElementById("email").value),
company: cleanValue(document.getElementById("company").value),
services_needed: cleanValue(document.getElementById("services_needed").value),
help: cleanValue(document.getElementById("help").value),
turnstile_token: turnstileToken, // ✅ Send token to server
});
try {
const response = await fetch("/wp-admin/admin-ajax.php", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" },
body: payload.toString(),
});
const raw = await response.text();
let result;
try {
result = JSON.parse(raw);
} catch (err) {
console.error("admin-ajax.php returned non-JSON:", raw);
if (statusEl) statusEl.textContent = "Server error (non-JSON response). Check console.";
alert("Server error. Check console for details.");
return;
}
if (result.success) {
if (statusEl) statusEl.textContent = "Saved to Airtable. Sending to HubSpot...";
form.submit();
return;
}
const msg =
result?.data?.airtable?.error?.message ||
result?.data?.message ||
result?.data ||
"Error submitting the form. Please try again.";
console.error("Proxy/Airtable full error:", result);
if (statusEl) statusEl.textContent = msg;
alert(msg);
} catch (error) {
console.error("Fetch error:", error);
if (statusEl) statusEl.textContent = "Unexpected error occurred.";
alert("Unexpected error occurred.");
} finally {
if (submitBtn) submitBtn.disabled = false;
}
});
});
/* ---------- FORM CONTAINER ---------- */
#airtable-form {
display: flex;
flex-wrap: wrap;
gap: 1rem;
max-width: 800px;
margin: auto;
font-family: "Poppins", sans-serif;
background: #fff;
padding: 2rem;
border-radius: 8px;
}
/* ---------- FIELD GROUPS ---------- */
.form-group {
display: flex;
flex-direction: column;
}
.form-group.half {
flex: 1 1 calc(50% - 0.5rem);
min-width: 200px;
}
.form-group.full {
flex: 1 1 100%;
}
/* ---------- LABELS ---------- */
#airtable-form label {
margin-bottom: 0.4rem;
font-weight: 600;
color: #000;
}
/* ---------- INPUTS, SELECT, TEXTAREA ---------- */
#airtable-form input,
#airtable-form select,
#airtable-form textarea {
padding: 0.8rem;
border: 1px solid #ccc;
border-radius: 6px;
font-size: 16px;
width: 100%;
box-sizing: border-box; /* ✅ prevents width overflow */
background: #e8ebef;
color: #000;
font-family: "Poppins", sans-serif; /* ✅ consistent font in textarea */
}
/* ---------- SELECT ---------- */
#airtable-form select {
appearance: none;
-webkit-appearance: none; /* ✅ Safari fix */
padding-right: 2.5rem;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='10' viewBox='0 0 14 10' fill='none' stroke='%23000' stroke-width='2'%3E%3Cpolyline points='1 3 7 9 13 3'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right 0.75rem center;
background-size: 1rem;
background-color: #e8ebef; /* ✅ explicit so it doesn't get overridden */
cursor: pointer;
}
/* ---------- TEXTAREA ---------- */
#airtable-form textarea {
resize: vertical;
min-height: 120px; /* ✅ ensures it renders visibly */
}
/* ---------- TURNSTILE ---------- */
.form-group.full .cf-turnstile {
margin-top: 0.25rem;
}
/* ---------- BUTTON ---------- */
#airtable-form button {
font-size: 18px;
background: #26a6c5;
color: #fff;
border: none;
border-radius: 32px;
padding: 17px 44px;
cursor: pointer;
font-family: "Poppins", sans-serif;
}
#airtable-form button:hover {
background: #1c8aa8;
}
#airtable-form button:disabled {
opacity: 0.6;
cursor: not-allowed;
}
/* ---------- STATUS MESSAGE ---------- */
#form-status {
max-width: 800px;
margin: 0.5rem auto 0;
font-family: "Poppins", sans-serif;
font-size: 14px;
color: #c0392b;
}
/* ---------- RESPONSIVE ---------- */
@media (max-width: 640px) {
.form-group.half {
flex: 1 1 100%;
}
#airtable-form {
padding: 2rem 1rem;
}
#airtable-form button {
padding: 10px 20px;
}
}














