# Email Input Field Trigger





<Warning>
  **WAIT...** Make sure that you have added the [**Surface Tag**](/docs/surface-tag/installation) to your site before proceeding.
</Warning>

## 1. Add the HTML Form [#1-add-the-html-form]

Ensure your HTML form includes the `surface-form-handler` class. This class is essential for identifying the form as one that triggers the Surface Form popup. Example:

```html
<form class="surface-form-handler">
  <input type="email" placeholder="Enter your email" required />
  <button type="submit">Submit</button>
</form>
```

<Note>
  Add the &#x2A;*`surface-form-handler`** class to any external form that you want to use to trigger the Surface Form popup.
</Note>

## 2. Modify the Surface Form Embedding Script [#2-modify-the-surface-form-embedding-script]

Modify the Surface Form Embedding Script to include the `data-question-id` attribute.

<Note>
  You must replace the &#x2A;*`<question_id>`*&#x2A; within &#x2A;*`data-question-id`** attribute below with the question ID from the Surface Form Builder.
</Note>

<Frame>
    <img alt="Question ID Location" src="__img0" />
</Frame>

```html
<!-- Start Surface Form Embed -->

<script data-question-id="<question_id>">
  (function () {
    const surface_src = "surface_form_url";
    const surface_embed_type = "slideover"; // works on all embedding types!
    const target_element_class = "surface-form-button";
    const c = new SurfaceEmbed(
      surface_src,
      surface_embed_type,
      target_element_class,
    );
  })();
</script>

<!-- End Surface Form Embed -->
```

## 3. Test Your Integration [#3-test-your-integration]

* Enter a valid email in the input field and press "Submit" or hit "Enter".
* Verify that the Surface Form popup is displayed as expected.

Now you should be able to trigger a Surface Form popup from an external email input field!

## Optimize Speed [#optimize-speed]

Add the following `<link>` tags inside the `<head>` of your site:

```html
<!-- Speed up connections to forms.withsurface.com by performing early DNS resolution and TCP handshake -->
<link rel="dns-prefetch" href="https://forms.withsurface.com">
<link rel="preconnect" href="https://forms.withsurface.com" crossorigin>

<!--  Fetch the form in advance, so it's ready when a user opens it. -->
<link rel="prefetch" href="REPLACE ME WITH FORM URL" as="document">
```

<Info>
  Replace `REPLACE ME WITH FORM URL` with a Surface Form URL.
</Info>

## Explanation [#explanation]

1. dns-prefetch → Resolves the domain early to skip DNS lookup delays.
2. preconnect → Prepares the TCP + TLS handshake so the browser is ready to request assets immediately.
3. prefetch → Fetches the form in advance, so it's ready when a user opens it.
