Email Validate provides email address validation service that returns the status of the validated email address. Before starting, open sample.html file in any text editor and ensure that email.js script is uncommented:
<script type="text/javascript" src="js/email.js">script>
Simple Integration
1. Import email.js to your Html page:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>QAS Email Validate</title>
<script type="text/javascript" src="js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="js/email.js"></script>
</head>
<body>
</body>
</html>
2. Define <label>
and <input>
elements in the <body>
tag. The <input>
element's value will be the email address that will be validated.
3. Define a <textarea>
element in the <body>
tag. The <textarea>
element will be used to display the email validation result:
<body>
<label for="emailTextBox">Email</label>
<input id="emailTextBox" type="text">
<br>
<textarea id="result" style="width:330px; height:630px"></textarea>
</body>
4. Initialize the emailValidation object and passing in the <input>
element as part of the required parameter.
5. Assign both the onSuccessHandler and onErrorHandler functions:
<body>
<label for="emailTextBox">Email</label><input id="emailTextBox" type="text">
<script type="text/javascript">
$(document).ready(function() {
var $plugin = new emailValidation(
$( "#emailTextBox"), {
onSuccess: onSuccessHandler,
onError: onErrorHandler
});
function onSuccessHandler(data) {
// Success callback implementation
$( "#result").val(JSON.stringify(data,null, 2));
};
function onErrorHandler(jqXHR, status, errThrown) {
// Error callback implementation
$( "#result").val(JSON.stringify(jqXHR,null, 2));
};
});
</script>
6. The completed page will look something like this:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>QAS Email Validate</title>
<script type="text/javascript" src="js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="js/email.js"></script>
</head>
<body>
<label for="emailTextBox">Email</label>
<input id="emailTextBox" type="text">
<br>
<textarea id="result" style="width:330px; height:330px"></textarea>
<script type="text/javascript">
$(document).ready(function() {
var $plugin = new emailValidation(
$( "#emailTextBox"), {
onSuccess: onSuccessHandler,
onError: onErrorHandler
});
function onSuccessHandler(data) {
// Success callback implementation
$( "#result").val(JSON.stringify(data,null, 2));
};
function onErrorHandler(jqXHR, status, errThrown) {
// Error callback implementation
$( "#result").val(JSON.stringify(jqXHR,null, 2));
};
});
</script>
</body>
</html>
7. Test your implementation by entering your email address in the textbox:
Advanced Options
These are advanced options for email.js:
Option | Description |
---|---|
proxyPath | Path pointing to the email proxy file. |
featureVersion | Email Validate feature version. Currently, only version 1.0 is supported. |
timeout | Timeout in milliseconds (ms) for the call to the proxy file. |
inlineMode | True - email validation will be triggered when the textbox loses focus. False - email validation has to be triggered manually. |
showLoading | True - loading HTML will be rendered during validation.False - loading HTML will not be rendered during validation. |
styles | CSS style classes used by the email.js plugin to generate the HTML. |
messages | Messages to display in the generated HTML by the email.js plugin |
onSuccess | Success handler that will be called whenever the email validation is successful. |
onError | Error handler that will be called when there an error occurs while performing email validation. |
Example:
var $plugin = new emailValidation(
$( "#emailTextBox"), {
proxyPath: "emailValidation.ashx",
featureVersion: "1.0" ,
timeout: 10000,
inlineMode: true,
showLoading: true,
onSuccess: function (data) {
// onSuccess callback implementation
},
onError: function (jqXHR, status, errThrown) {
// onError callback implementation
},
messages: {
emptyEmail: "Please enter email.",
error: "Please contact Experian QAS support.",
timeout: "Timeout."
},
styles: {
success: "success",
successInline: "success-inline",
error: "error",
errorInline: "error-inline",
loading: "loading",
correctionEmail: "correctionEmail",
emailPicklistHeader: "emailPicklistHeader",
emailPicklist: "emailPicklist",
picklistItem: "picklistItem",
picklistItemText: "picklistItemText",
closeButton: "closeButton",
}
});