For example, email address [email protected] pass the built in regular expression based validation but thats not the existing email address.Webservices like can give you an option of validating email for its existence.

validating email field-39

If a field fails validation, reveal field validation advice and prevent the form from submitting.

So basically in Magento you end up with form fields like validation.

You are not satisfied with it because it only does the regular expression validation and not the “real deal”.

Imagine you want to check if each email address actually exist in the world, not just if it is in proper format.

For example [email protected]', function(v) { var url = '/mycontroller/my Validate Action/email?

email=' + encode URIComponent(v); var ok = false; new Ajax.

Request(url, { method: 'get', asynchronous: false, on Success: function(transport) { var obj = response = eval('(' + transport.response Text + ')'); validate True Email Msg = obj.status_desc; if (=== false) { Validation.get('validate-email').error = validate True Email Msg; ok = false; } else { ok = true; /* return true or false */ } }, on Complete: function() { if ($('advice-validate-email-email')) { $('advice-validate-email-email').remove(); } if ($('advice-validate-email-email_address')) { $('advice-validate-email-email_address').remove(); } if ($('advice-validate-email-billing:email')) { $('advice-validate-email-billing:email').remove(); } if ($('advice-validate-email-shipping:email')) { $('advice-validate-email-shipping:email').remove(); } if ($('advice-validate-email-_accountemail')) { $('advice-validate-email-_accountemail').remove(); } } }); return ok; }); Example above does an synchronous AJAX call towards the custom controller action which in turn calls and handles the response from API then returns the proper response to the AJAX.

In this short article I will show you a quick way of adding an AJAX-ed validation on Magento form field.

If you open up the {MAGENTO_ROOT}/js/prototype/file and look into its header comments you will see that Magento’s Java Script validation is actually done trough 3rd party Java Script library called Really Easy Field Validation by an author named Andrew Tetlaw, with its own GIT repository available here.