Getting Started

Slapform works with any HTML form as well as AJAX.

Simple HTML Form Example

To use Slapform with an HTML form, you just need to change a few things:

  1. Point the action attribute to our endpoint
  2. Include name attributes in your form
  3. That's it!

Copy-paste this code and just change [email protected] to your own email.

    
      <form method="POST"
        action="https://api.slapform.com/[email protected]">
        <input type="email" name="email">
        <textarea type="text" name="message"></textarea>
        <button type="submit">Submit</button>
      </form>
    
  

Each <input> element needs to have the name attribute in order to be received properly by Slapform.

The action="..." part of the form defines where your form data will be sent to. Usually, developers will enter something like http://mysite.com/form.php. The form.php file would then parse the received data in a server-side scripting language like Node.js, PHP, Python, Ruby, or Perl.

Upon submitting a form you've enabled with Slapform, you simply receive the data in an email. No backend code required!

Simple AJAX Example

You can also submit forms using Ajax. Like the HTML form, it's very simple to set up:

  1. Point the url to our endpoint and add your email at the end
  2. Include your submission in the data object
  3. That's it!

Copy-paste this code and just change [email protected] to your own email.

    
      <script
      src="https://code.jquery.com/jquery-3.2.1.min.js"
      integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
      crossorigin="anonymous"></script>

      <script type="text/javascript">
        $( document ).ready(function() {
          $.ajax({
            url: 'https://api.slapform.com/[email protected]', /* replace '[email protected]' with your email */
            dataType: "json",
            type: 'POST',
            data: {
              name: "Jon Snow",
              message: "Hello World! This is where the message will go."
            },
            success: function (response) {
                console.log("Response: ", response);
            }
          });
        });
      </script>
    
  

You can read more about using AJAX submissions in Slapform to get a better idea of how to use AJAX.

Extending Slapform

Slapform can be easily extended to do some pretty advanced stuff:

  1. Include advanced name triggers to customize the email, push webhooks, and more
  2. Go beyond forms and submit data with AJAX. Learn how to submit AJAX