0

I've added a new validation option in the validation.js... My question now is, when I update magento to a newer version, will my javascript file be overwritten by a new version?

Current path = /js/prototype/validation.js

Where do I save this file or overwrite this?

Gerard de Visser
  • 7,590
  • 9
  • 50
  • 58
  • Yes, your file will be overwritten. Check out [this](http://stackoverflow.com/questions/11941257/overriding-extending-the-magento-core-javascript-files) – Roman Shopin Jun 10 '14 at 12:55

1 Answers1

0

You can do something like this directly in your phtml file :

    Validation.add('validate-email', '<?php echo $this->__('This is a required field.') ?>', function(v) {
    var email = v;
    var parameters = { email: email };
    var value = Validation.get('IsEmpty').test(v) || /^([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(v)

    return value;
});
zaka47
  • 83
  • 1
  • 6