["validate-email","Please enter a valid email address. For example johndoe@domain.com.",function(e){return Validation.get("IsEmpty").test(e)||/^([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*@([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*\.(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]){2,})$/i.test(e)}]

The type of email in which backlash is there e.g. john/smith@domain.com, john#smith#@domain.com or john*smoth@domain.com are not showing error for validation of emails.

What I can do to fix?


Create a new javascript file and place it in /js folder.

For example : js/validation-override.js

Validation.add("validate-email","Please enter a valid email address. For example john_smith@domain.com.",function(e){return Validation.get("IsEmpty").test(e)||/^([\w-\.]+)@(([[0-9]‌​{1,3}\.[0-9]{1,3}\.[‌​0-9]{1,3}\.)|(([\w-]‌​+\.)+))([a-zA-Z]{2,4‌​}|[0-9]{1,3})(]?‌​)$/i.test(e)})

Add this code inside your theme layout xml file app/design/frontend/your_theme/default/layout/page.xml :

    <reference name="head">
        <action method="addJs"><script>validation-override.js</script></action>

You can find more information here : http://inchoo.net/magento/out-of-the-box-form-validation-in-magento/

  • Doesn't work john/smith@domain.com, john#smith#@domain.com still validating.. – Shoeb Mirza Feb 8 '17 at 17:57
  • Are you sure your overriden JS file is loaded? Maybe browser cache? – Jonathan Ribas Feb 8 '17 at 19:08
  • Yeah, your code is working but it doesn't achieve what I wanted. I just don't understand how to avoid special characters in the names except "fullstop" and "underscore" – Shoeb Mirza Feb 8 '17 at 19:17
  • For what you want to achieve you have to change the regular expression in js/validation-override.js – Jonathan Ribas Feb 9 '17 at 10:09
  • Let's say I don't want to allow John/Smit@domain.com type or John*Smith@domain, how can I achieve this by changing regular expression? – Shoeb Mirza Feb 9 '17 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.