The LeadSpend Email Validation jQuery Plugin automatically validates email addresses as soon as they are typed in, and is designed to work well with your current site no matter how you're validating the form.
LeadSpend uses domain-based authentication, so this will not work on your site until we have authorized your domain. Contact us for more information.
This plugin was designed to work right out of the box with zero-configuration. All you need to do is:
Include jquery:
<script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js"></script>Import jquery-leadspendemail:
<script type="text/javascript" src="../../jquery.leadspendemail.js"></script>Add the class "leadSpendEmail-noconfig" to the email input on your form:
<input class="leadSpendEmail-noconfig" name="email-input">The LeadSpend result will appear in a hidden input on your form, available to use with your current form validation.
LeadSpend Email Validation is also a fully featured jQuery plugin. This means that it is called using a jQuery selector, and can be passed a map of options, or PlainObject. To use custom options, remove the "leadSpendEmail-noconfig" class from your email input and call the plugin directly:
$(function(){
$('{email-input-selector}').leadSpendEmail( options );
});The following options may be passed to the plugin:
| Value | Description | Type | Default Value |
|---|---|---|---|
| timeout | The timeout, in seconds. | Integer from 3 to 15 | 5 |
| debug | Enables console logging. | Boolean | false |
| delaySubmit | Delays form submit until the API call returns. | Boolean | true |
The email validation result will be stored in a hidden input as part of your form. This input will have the following attributes:
- name = "{name of your email input}-result"
- id = "{id of your email input}-result" (or "" if ID was not set on your form)
- class = "leadSpendEmail-result"
When a result is returned, the "change" event is triggered on the hidden result input.
The easiest way to access this value in JavaScript will be to use jQuery:
var result = $("#{id of your email input}-result").val();The result will also be available server-side:
$result = $_GET["{name of your email address input}-result"];LeadSpend defines the validity of an email address as follows:
| Value | Description |
|---|---|
| verified | Mailbox exists, is reachable, and not known to be illegitimate or disposable. |
| disposable | Domain is administered by disposable email provider (e.g. Mailinator). |
| unreachable | Domain has no reachable mail exchangers (see discussion, below). |
| illegitimate | Seed, spamtrap, black hole, technical role account or inactive domain. |
| undeliverable | Mailbox or domain does not exist, or mailbox is full, suspended or disabled. |
| unknown | We were unable to conclusively verify or invalidate this address. |
More detail can be found at our API Documentation.
In addition to these result codes, this plugin defines two status codes as follows:
| Value | Description |
|---|---|
| pending | The email validation API call has not yet completed. |
| error | There was an error while making the API call to the LeadSpend servers. |
Included in the demo folder are a variety of pages which demostrate usage of the LeadSpendEmail plugin. These fall into two categories:
Various configurations of the plugin, by itself. This is the place to start if you plan on using the plugin with your existing front-end or server-side form validation.
- automatic.html: Fully-automatic, out of the box configuration. Automatially delays form submission until the API result has returned.
- custom.html: Demonstrates passing basic configurations to the plugin, such as debugging, timeout and turning off delaySubmit.
Demonstrates the use of the plugin in conjunction with jQuery Validate. If you have no existing validation on your form or would like to quickly add very good JavaScript validation, this is for you. jQuery Validate is an extremely powerful tool that allows you to add specific validation controls to your form by simply adding CSS classes. Find out more in the jQuery Validate documentation.
- automatic.html: Fully-automatic, out of the box configuration using the zero-configuration jquery.leadspendemail.js in conjunction with jQuery Validate. Includes a script which configures jQuery Validate for fully automatic form validation.