Skip to content

Commit d2a2d3b

Browse files
committed
Migrate contact form from 99inbound to FormSubmit.co
1 parent aec56f4 commit d2a2d3b

2 files changed

Lines changed: 6 additions & 98 deletions

File tree

layouts/contact/single.html

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ <h3>Denver, Colorado, USA</h3>
7373
<div class="container">
7474
<div class="row">
7575
<div class="col-11 m-auto">
76-
<form id="contact">
76+
<form action="https://formsubmit.co/hello@automatedascent.com" method="POST">
77+
<input type="hidden" name="_subject" value="New contact form submission">
78+
<input type="hidden" name="_next" value="https://automatedascent.com/contact/">
79+
<input type="text" name="_honey" style="display:none">
80+
<input type="hidden" name="_captcha" value="false">
7781
<div class="row">
7882
<!-- Name -->
7983
<div class="col-md-6">
@@ -117,24 +121,12 @@ <h3>Denver, Colorado, USA</h3>
117121
maxlength="5000"
118122
aria-label="Your message"></textarea>
119123
</div>
120-
<!-- Honeypot field (hidden from users, catches bots) -->
121-
<div class="col-md-12 honeypot-field" aria-hidden="true">
122-
<input type="text" id="honeypot" name="website" tabindex="-1" autocomplete="off">
123-
</div>
124124
<!-- Submit Button -->
125125
<div class="col-12 text-right">
126-
<button type="submit" class="btn btn-main-md" id="submit-btn">Submit</button>
126+
<button type="submit" class="btn btn-main-md">Submit</button>
127127
</div>
128128
</div>
129129
</form>
130-
<div class="alert alert-success alert-hidden" id="contact-success">
131-
<h4 class="alert-heading">Great!</h4>
132-
<p>We received your details and will be in touch shortly.</p>
133-
</div>
134-
<div class="alert alert-danger alert-hidden" id="contact-error">
135-
<h4 class="alert-heading">Something went wrong!</h4>
136-
<p>Please send us an email instead.</p>
137-
</div>
138130
</div>
139131
</div>
140132
</div>

static/js/custom.js

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -81,90 +81,6 @@
8181
var video = '<iframe allowfullscreen src="' + $(this).attr('data-video') + '"></iframe>';
8282
$(this).replaceWith(video);
8383
});
84-
85-
// -----------------------------
86-
// Contact Form
87-
// -----------------------------
88-
89-
// Rate limiting: Track last submission time
90-
var lastSubmissionTime = 0;
91-
var submissionCooldown = 60000; // 60 seconds between submissions
92-
93-
// Simple input sanitization function
94-
function sanitizeInput(input) {
95-
var div = document.createElement('div');
96-
div.appendChild(document.createTextNode(input));
97-
return div.innerHTML;
98-
}
99-
100-
$('#contact').submit(function(event) {
101-
event.preventDefault();
102-
103-
// Rate limiting check
104-
var currentTime = Date.now();
105-
if (currentTime - lastSubmissionTime < submissionCooldown) {
106-
var remainingTime = Math.ceil((submissionCooldown - (currentTime - lastSubmissionTime)) / 1000);
107-
alert('Please wait ' + remainingTime + ' seconds before submitting again.');
108-
return false;
109-
}
110-
111-
// Honeypot check - if filled, it's likely a bot
112-
if ($('#honeypot').val() !== '') {
113-
console.log('Spam detected');
114-
$('#contact').remove();
115-
$('#contact-error').fadeIn();
116-
return false;
117-
}
118-
119-
// Get and sanitize form values
120-
var name = sanitizeInput($('#name').val().trim());
121-
var email = sanitizeInput($('#email').val().trim());
122-
var message = sanitizeInput($('#message').val().trim());
123-
124-
// Additional validation
125-
if (name.length < 2 || name.length > 100) {
126-
alert('Name must be between 2 and 100 characters');
127-
return false;
128-
}
129-
130-
if (email.length > 255) {
131-
alert('Email address is too long');
132-
return false;
133-
}
134-
135-
if (message.length < 10 || message.length > 5000) {
136-
alert('Message must be between 10 and 5000 characters');
137-
return false;
138-
}
139-
140-
// Disable submit button to prevent double submission
141-
var submitBtn = $('#submit-btn');
142-
submitBtn.prop('disabled', true);
143-
submitBtn.text('Sending...');
144-
145-
$.ajax({
146-
method: "POST",
147-
url: "https://app.99inbound.com/api/e/74bnVMQv",
148-
data: {
149-
name: name,
150-
email: email,
151-
message: message
152-
},
153-
timeout: 30000, // 30 second timeout
154-
success: function (data) {
155-
lastSubmissionTime = Date.now();
156-
$('#contact').remove();
157-
$('#contact-success').fadeIn();
158-
},
159-
error: function (xhr, status, error) {
160-
console.error('Form submission error:', status, error);
161-
submitBtn.prop('disabled', false);
162-
submitBtn.text('Submit');
163-
$('#contact').remove();
164-
$('#contact-error').fadeIn();
165-
}
166-
});
167-
});
16884
});
16985

17086
})(jQuery);

0 commit comments

Comments
 (0)