Hi Taare,
Let’s create our javascript file and place it in the js folder.
js/custom.js
Validation.add('validate-email', 'Please enter a valid Gmail address. For example johndoe@gmail.com.', function(v) {
// here write your logic
});
All we need to do now is include our validation script. We’ll do that using Magento’s addJs method which will add the javascript file to our website’s head.
<default>
<reference name="head">
<action method="addJs"><script>custom.js</script></action>
</reference>
</default>
You can do this from any layout file (preferably your module’s layout file), Magento did it in their theme’s layout page called page.xml located in app/design/frontend/base/default/layout/page.xml