Switch contact form to FormSubmit.co
- Replace /api/contact POST with FormSubmit.co action - Add honeypot anti-spam, success banner, FormData handler
This commit is contained in:
parent
a685df00c0
commit
bd4919ff4b
88
index.html
88
index.html
@ -267,29 +267,47 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="lg:col-span-7 bg-slate-950 rounded-3xl p-10">
|
<div class="lg:col-span-7 bg-slate-950 rounded-3xl p-10">
|
||||||
<form id="contactForm" class="space-y-8">
|
<form id="contact-form" action="https://formsubmit.co/info@moxiegen.com" method="POST" class="space-y-8">
|
||||||
|
|
||||||
<div class="grid grid-cols-2 gap-6">
|
<div class="grid grid-cols-2 gap-6">
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm text-slate-400 mb-2">Your name</label>
|
<label class="block text-sm text-slate-400 mb-2">Your name</label>
|
||||||
<input type="text" id="contactName" placeholder="Jane Doe" class="w-full bg-slate-900 border border-slate-700 focus:border-emerald-400 rounded-2xl px-6 py-5 outline-none text-lg">
|
<input type="text" name="name" placeholder="Jane Doe"
|
||||||
|
class="w-full bg-slate-900 border border-slate-700 focus:border-emerald-400 rounded-2xl px-6 py-5 outline-none text-lg" required>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm text-slate-400 mb-2">Company</label>
|
<label class="block text-sm text-slate-400 mb-2">Company</label>
|
||||||
<input type="text" id="contactCompany" placeholder="Acme AI Labs" class="w-full bg-slate-900 border border-slate-700 focus:border-emerald-400 rounded-2xl px-6 py-5 outline-none text-lg">
|
<input type="text" name="company" placeholder="Acme AI Labs"
|
||||||
|
class="w-full bg-slate-900 border border-slate-700 focus:border-emerald-400 rounded-2xl px-6 py-5 outline-none text-lg" required>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm text-slate-400 mb-2">Work email</label>
|
<label class="block text-sm text-slate-400 mb-2">Work email</label>
|
||||||
<input type="email" id="contactEmail" placeholder="you@company.com" class="w-full bg-slate-900 border border-slate-700 focus:border-emerald-400 rounded-2xl px-6 py-5 outline-none text-lg">
|
<input type="email" name="email" placeholder="you@company.com"
|
||||||
|
class="w-full bg-slate-900 border border-slate-700 focus:border-emerald-400 rounded-2xl px-6 py-5 outline-none text-lg" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm text-slate-400 mb-2">Tell us about your use case</label>
|
<label class="block text-sm text-slate-400 mb-2">Tell us about your use case</label>
|
||||||
<textarea id="contactMessage" rows="4" placeholder="We run 400 H100s and want to run inference + training simultaneously..." class="w-full bg-slate-900 border border-slate-700 focus:border-emerald-400 rounded-3xl px-6 py-5 outline-none text-lg resize-none"></textarea>
|
<textarea name="message" rows="4" placeholder="We run 400 H100s and want to run inference + training simultaneously..."
|
||||||
|
class="w-full bg-slate-900 border border-slate-700 focus:border-emerald-400 rounded-3xl px-6 py-5 outline-none text-lg resize-none" required></textarea>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="w-full py-6 bg-emerald-400 hover:bg-emerald-300 text-slate-950 font-semibold text-2xl rounded-3xl">
|
|
||||||
|
<!-- Hidden fields -->
|
||||||
|
<input type="hidden" name="_subject" value="New Moxiegen Website Inquiry!">
|
||||||
|
<input type="text" name="_honey" style="display:none">
|
||||||
|
|
||||||
|
<button type="submit"
|
||||||
|
class="w-full py-6 bg-emerald-400 hover:bg-emerald-300 text-slate-950 font-semibold text-2xl rounded-3xl">
|
||||||
Send message to Moxiegen
|
Send message to Moxiegen
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<!-- Success message area -->
|
||||||
|
<div id="success-message" class="hidden mt-6 text-center py-4 bg-emerald-400/10 border border-emerald-400 rounded-3xl text-emerald-400 font-medium">
|
||||||
|
✅ Message sent successfully! We'll get back to you soon.
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -502,63 +520,35 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ============================================
|
// ============================================
|
||||||
// FORM SUBMIT HANDLER
|
// FORM SUBMIT HANDLER (FormSubmit.co)
|
||||||
// ============================================
|
// ============================================
|
||||||
function initContactForm() {
|
function initContactForm() {
|
||||||
const form = document.getElementById('contactForm');
|
const form = document.getElementById('contact-form');
|
||||||
if (!form) return;
|
const successDiv = document.getElementById('success-message');
|
||||||
|
|
||||||
form.addEventListener('submit', async (e) => {
|
form.addEventListener('submit', async function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
const button = form.querySelector('button[type="submit"]');
|
const formData = new FormData(form);
|
||||||
const originalText = button.innerHTML;
|
|
||||||
|
|
||||||
const name = document.getElementById('contactName').value.trim();
|
|
||||||
const company = document.getElementById('contactCompany').value.trim();
|
|
||||||
const email = document.getElementById('contactEmail').value.trim();
|
|
||||||
const message = document.getElementById('contactMessage').value.trim();
|
|
||||||
|
|
||||||
if (!name || !email || !message) {
|
|
||||||
alert('Please fill in all required fields.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
button.innerHTML = '<span class="inline-block animate-spin mr-3">⟳</span> Sending...';
|
|
||||||
button.disabled = true;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/contact', {
|
const response = await fetch(form.action, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
body: formData
|
||||||
body: JSON.stringify({ name, company, email, message })
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = await response.json();
|
if (response.ok) {
|
||||||
|
successDiv.classList.remove('hidden');
|
||||||
if (data.success) {
|
|
||||||
button.innerHTML = '✓ Message Sent!';
|
|
||||||
button.style.background = '#22c55e';
|
|
||||||
form.reset();
|
form.reset();
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
button.innerHTML = originalText;
|
successDiv.classList.add('hidden');
|
||||||
button.disabled = false;
|
}, 6000);
|
||||||
button.style.background = '';
|
|
||||||
}, 3000);
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error(data.message || 'Failed to send message');
|
alert('Something went wrong. Please try again.');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Contact form error:', error);
|
alert('Network error. Please check your connection and try again.');
|
||||||
button.innerHTML = '✗ Failed to send';
|
|
||||||
button.style.background = '#ef4444';
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
button.innerHTML = originalText;
|
|
||||||
button.disabled = false;
|
|
||||||
button.style.background = '';
|
|
||||||
}, 3000);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user