QuickEmailVerification JavaScript Widget provides the qev object to deal with email verification programmatically. It contains a few properties and methods to provide you with an ability to access extra details about the verification result or override the default behavior of the widget and set your own routine to perform email verification.

error

This property contains the error message returned during last email verification (if any). Few possibilities of facing error can be a misconfiguration of allowed domains or your QuickEmailVerification account has low credit balance.

console.log(qev.error);

prevVerification

Last verification email value can be checked using the prevVerification property of qev object. It's helpful to avoid duplicate verification if you are using the verify() method of qev.api object (explained later in this section). If the email input is not changed since last verification and the user attempts to submit the form again, you may check qev.prevVerification and utilize the previous verification result.

console.log(qev.prevVerification);

response

This property contains the full response of the email verification call performed by the QuickEmailVerification JavaScript widget. The response will be in JSON format containing detailed information of verification result. It is helpful in establishing a special validation rule to allow only specific users. For example, if you want to deny users from specific email network, you may check the qev.response.mx_domain and qev.response.mx_record fields and decide whether to allow the user or not.

console.log(JSON.stringify(qev.response));

api

If you do not want to use the default options provided by the QuickEmailVerification JavaScript Widget, you can use qev.api object and perform email verification on your own and as per your need. Below is the list of methods supported by qev.api object.

verify(emailValue, successCallback, failureCallback);

The first argument accepts the email address to be verified. The successCallback and failureCallback arguments accepts callback functions which will be executed upon email verification result returned by widget. You can add a desired set of actions in these callback functions. If the email address has passed the verification checks, successCallback gets executed while email addresses failed during the verification process will call failureCallback.

qev.api.verify('support@quickemailverification.com',
	function(result) {
		console.log("suc callback");
		console.log(JSON.stringify(result));
	},
	function(error) {
		console.log("fail callback");
		console.error(error);
	}
);

addListener(field)

When you do not want to autoRegister input fields with the widget (by default widget detects email fields automatically from the page on which its installed) or when you want to register dynamic fields with the widget, you may need to use this method. The only argument that the addListener() method accepts is the input field which is required to register for email verification. Registered fields will then behave just like auto registered fields and will verify user email on blur event of the input field. Here's the example,

var field = document.querySelector("input[id='email_field_to_register']");
qev.api.addListener(field);

removeListener(field)

Sometimes, you may need to dynamically remove fields from the DOM and un-register all listeners of that field. You can use removeListener() method of qev.api object to clear all the listeners attached to the field. Pass the field to unregister as the argument to the method. Here's the example,

var field = document.querySelector("input[id='email_field_to_unregister]");
qev.api.removeListerner(field);