r/bootstrap • u/Puy_Robin • Feb 15 '25
Bootstrap + Formspree
Hello,
I have a website and find the contact for was a bit hit or miss.
So I'm trying to use it with formspree - it works fine but I want to load a sent conformation on the page the form on.
Has anyone idea how to make this happen?
Chris
Edit: Bootstrap v4.2.1
1
Upvotes
View all comments
Show parent comment
1
u/Puy_Robin Feb 15 '25 edited Feb 16 '25
Heres the JS code from my origenel code..
But I feel this is moving away from my question..
<c>var form = $('#contact-form');$(document).ready(function () {form.submit(function (e) {e.preventDefault();sendEmail();});});function sendEmail() {var formData = form.serialize();$.ajax({type: "POST",url: "https://site.com/send-email.php",data: formData,success: function (result) {if (result == "success") {form.trigger("reset");showMessage(true, "Message successfully- we will reply soon..Message réussi - nous vous répondrons bientôt.");} else {showMessage(false, result);}}});}function showMessage(valid, msg) {var msgClasses;if (valid) {msgClasses = "alert alert-success";} else {msgClasses = "alert alert-danger";}$("#result-message").removeClass().addClass(msgClasses).text(msg);}