How do you create a contact form?

I’ve looked everywhere I could think of but don’t see anyway to create a contact form. I’m assuming I’ll need some javascript or a third party form but what is the recommendation?

You are correct about the third party part.

I have not seen any recommendation, so I guess none has been recommended. We have some opinions on the discussion part, so we should maybe also have some opinions here …

1 Like

I used formspree.io with some JS to perform the submission so that I could control the result (thanks, we have your details…) but you can also do a simple POST from a form with some hidden fields.

Check out their API.

3 Likes

Care to share that JS?

Sure!

I have a form with an ID of contact that contains the fields I need, then this JS does the magic:

$(document).ready(function(){
  $('#contact').submit(function(event) {
    $.ajax({
      dataType: "json",
      method: "POST",
      url: "//formspree.io/info@yourdomain.com",
      data: {
        message: $('#message').val(),
        email: $('#email').val(),
        _subject: "Your Site - Contact Form",
        name: $('#name').val()
      }
    }).done(function(data) {
      $('#contact').remove();
      $('.alert').fadeIn();
    });
    event.preventDefault();
  });
});

There is an alert DIV that is faded in to report the feedback:

<div class="alert alert-success" role="alert" style="display:none;"><strong>Great!</strong> We have got your details and someone will be in touch.</div>
2 Likes