Tuesday, April 12, 2011

Adding 'on the fly' form validation

Here is how you can add 'on the fly' validation for forms in Magento. I mean to validate the forms not only on submit but after editing a field.
Put the following line in a js file included in all the pages or in the <head> tag
Validation.defaultOptions.immediate = true; 

If you also want the classes of the validation to be added not only for the input but fur it's parent also add the following line in the same place as the one above.
Validation.defaultOptions.addClassNameToContainer = true;

Hope it helps

No comments:

Post a Comment