Skip to the content

jQuery Telephone & Email Validation

Quickly add detailed telephone number & email address validation to your website.


Basics

Our JavaScript library adds our telephone number and email address validation services into the jQuery Validation framework.

If you're already using jQuery Validation to validate data entered on your website, in just a few minutes you can extend it to use our services to greatly improve the validation level of your telephone number and email address fields.

Add our library with two lines of code:

<script type="text/javascript" src="https://webservices.data-8.co.uk/javascript/loader.ashx?key=your-api-key&load=PhoneValidation,EmailValidation"></script>
<script type="text/javascript" src="https://webservices.data-8.co.uk/javascript/jqueryvalidation_min.js"></script>

Replace your-api-key in the URL with your own API Key that you can get from your dashboard.

Once you've included our library you can set it to work by adding our rules to your jQuery Validation configuration:

<input type="tel" name="telephone" class="required d8val_phone" />
<input type="email" name="email" class="required d8val_email" />

Example

Try our jQuery Validation yourself in our form below.

Configuration

Get started with the most common configuration settings

As this library simply adds rules to the existing jQuery Validation framework, you can continue to add rules to your form as normal and jQuery Validation will check them as for any other rule type. The following new rule types are available:

Rule Description
d8val_phone The field is validated using our Phone Validation service.
d8val_email The field is validated using our Email Validation service.
d8val_inttelephone The field is validated using our International Telephone Validation service.

This option is deprecated in favour of the d8val_phone option. If you do use this option, ensure that InternationalTelephoneValidation is included in your loader.ashx?load= tag.

d8val_inttelephone_mobile As d8val_inttelephone but using the more advanced Mobile Validation service when the telephone number is recognised as a mobile number.

This option is deprecated in favour of the d8val_phone option. If you do use this option, ensure that InternationalTelephoneValidation is included in your loader.ashx?load= tag.

d8val_inttelephone_line As d8val_inttelephone but using the more advanced Telephone Line Validation service when the telephone number is recognised as a UK landline.

This option is deprecated in favour of the d8val_phone option. If you do use this option, ensure that InternationalTelephoneValidation is included in your loader.ashx?load= tag.

d8val_inttelephone_mobile_line Combines d8val_inttelephone_mobile and d8val_inttelephone_line

This option is deprecated in favour of the d8val_phone option. If you do use this option, ensure that InternationalTelephoneValidation is included in your loader.ashx?load= tag.

Advanced Options

Our validation services can take additional options to control how they work.

These additional options can be specified in the jQuery Validation rules by adding _opt to the rule name and passing an array of { name, value } pairs to it, e.g.:

$("#form").validate({
  rules: {
    telephone: {
      required: "Enter a telephone number",
      d8val_phone_opt: [ { name: "BarredPrefixes", value: "+4490" } ]
    }
  }
});

This applies the BarredPrefixes option to the Phone Validation service to ensure that any UK premium rate number is marked as invalid. Remember to update the name on the field to match too.

To increase the level of validation that email validation is performed at, simply add the property d8validationlevelto the email input, and specify one of the available levels such as address.

For a full list of all the available options, please see the documentation for the individual services: