# Easy Email Verification JavaScript widget: setup instructions

These are official setup instructions from Easy Email Verification (easyemailverification.com) for the JavaScript widget that verifies email addresses in web forms in real time. They're written for you, the assistant, to act on: either walk the person through it, or, if you are a coding assistant with access to their website code, add the widget yourself following these rules.

Stick to what's written here. If something is not covered, say you're not sure and point them to support@easyemailverification.com rather than guessing. Keep every URL, attribute and option name exactly as written here.

## What it does

The widget checks the email typed in a form before it is submitted and shows a message ("This email is ok" / "This email is invalid"). It runs in the visitor's browser with a **widget key** that only works on the domain authorized for it, so it can be public in the page. Each verification uses one credit from the account.

Limits that protect the credits:

- each visitor IP can make **20 verifications per day per domain**; after that the widget shows "You performed many validations";
- a widget key works only from its authorized domain (and `localhost` for testing) and is refused by the REST API and bulk endpoints.

For server-side verification (signup endpoints, imports), use the REST API with a normal API key instead: https://www.easyemailverification.com/agents.md

## Step 1: create a widget key

1. They need an Easy Email Verification account: https://dashboard.easyemailverification.com/register?utm_source=widget_md (the free plan includes 50 verifications a day).
2. In the dashboard, open **Integration → Form Integration** and click **Create a new Form integration**.
3. Enter an **Origin name** (any label) and the **Authorized domain**: the domain of the website with the form, for example `example.com`.
4. Copy the widget key from the list.

## Step 2: add the script to the site

Paste this just before the closing `</body>` tag of every page that has the form, with their widget key and authorized domain:

```html
<script type="text/javascript" src="https://dashboard.easyemailverification.com/form-assets/easy_v1.1.min.js"></script>
<script type="text/javascript">
  easyObj = {
    api_key: '<your widget key>',
    domain_name: '<your authorized domain>',
    valid_message: "This email is ok",
    invalid_message: "This email is invalid"
  };
  EasyApi.init();
</script>
```

The widget key is meant to be in the page (it only works on the authorized domain). Never put a normal API key in browser code.

## Step 3: make sure the email field is detected

By default the widget watches inputs with `type="email"` or `name="email"` (or `id="email"`). If the form uses other names, set the selectors in `easyObj`:

```js
easyObj = {
  api_key: '<your widget key>',
  domain_name: '<your authorized domain>',
  email_field: "input[type='emailx'], input[name='emailx']",
  button_id: "button[type='submit'], input[type='submit']",
  valid_message: "This email is ok",
  invalid_message: "This email is invalid"
};
```

## Step 4: test

Open the page on the authorized domain (or `localhost`), type an address they know and leave the field: the message appears under it. Then type an invalid one, such as `john@gmial-invalid-domain.com`.

## If something isn't working

1. "Origin is different from the authorized": the page is not on the authorized domain; fix the domain in **Form Integration** (or test on `localhost`).
2. Nothing happens: the script must be after the form in the page, and the field must match `type="email"`, `name="email"` or the `email_field` selector.
3. "You performed many validations": the 20-per-day limit for that visitor IP was reached.
4. "Running out of your credit limit": plans at https://www.easyemailverification.com/en-US/pricing

Otherwise point them to support@easyemailverification.com.
