Is it possible in Magento to extend validation.js to add the ability to validate single elements as opposed to plete forms.
If it is not possible what is the most unobtrusive way of customizing the validation.js script
Is it possible in Magento to extend validation.js to add the ability to validate single elements as opposed to plete forms.
If it is not possible what is the most unobtrusive way of customizing the validation.js script
Share Improve this question asked Aug 6, 2012 at 18:37 Marty WallaceMarty Wallace 35.8k57 gold badges143 silver badges209 bronze badges3 Answers
Reset to default 10Based more on the detail provided in the ment to Francesco than the initial question - If validation is required validation for individual form elements onblur then you need to set the 'immediate' property of the Validation object to true like so...
Validation.defaultOptions.immediate = true;
This will cause validation to occur if an elements value has been changed and it looses focus.
I take it this is a site wide change - so I would normally place code such as this my themes js file but alternatively you can also place it in a template (obviously before your form object gets initialised) by enclosing it in script tags i.e..
<script type="text/javascript">
Validation.defaultOptions.immediate = true;
<script>
Create a CMS Block with a content like below, and add a Widget setting the Checkout page.
<script type="text/javascript">
$$('.validate-michael-jackson').first().observe('blur', function(elem){
if (elem.value == 'Michael Jackson') {
alert('Come on baby! Are you really Michael Jackson?');
}
});
</script>
take a look at this : Link
By what I remember you can easly add a new validation in your .phtml files by extending validation.js class