Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extend validation.js and validate single elements

Is it possible in Magento to extend validation.js to add the ability to validate single elements as opposed to complete forms.

If it is not possible what is the most unobtrusive way of customizing the validation.js script

like image 259
Marty Wallace Avatar asked Mar 26 '26 15:03

Marty Wallace


1 Answers

Based more on the detail provided in the comment 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>
like image 139
Drew Hunter Avatar answered Mar 29 '26 03:03

Drew Hunter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!