jQuery Telephone & Email Validation
Quickly add detailed telephone number & email address validation to your website.
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=InternationalTelephoneValidation,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_inttelephone" /> <input type="email" name="email" class="required d8val_email" />
Try our jQuery Validation yourself in our form below.
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_inttelephone |
The field is validated using our International Telephone Validation service. |
d8val_inttelephone_mobile |
As d8val_inttelephone but using the more advanced Mobile Validation service when the telephone number is recognised as a mobile number. |
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. |
d8val_inttelephone_mobile_line |
Combines d8val_inttelephone_mobile and d8val_inttelephone_line |
d8val_email |
The field is validated using our Email Validation service. |
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_inttelephone_opt: [ { name: "BarredPrefixes", value: "+4490" } ] } } });
This applies the BarredPrefixes
option to the International Telephone Validation service to ensure that any UK premium rate number is marked as invalid.
For a full list of all the available options, please see the documentation for the individual services: