Overriding Magento’s form error mechanisms

by c

Magento’s form error classes are pretty ugly and poorly designed. Luckily, it’s easy to override the methods located in prototype/validation.js.

Let’s allow validation on hidden form elements and start working on better looking advice when errors occur.

	Object.extend(Validation, {
		isVisible : function(elm) {
			return true;
		},
		insertAdvice : function(elm, advice){
			// advice contains the div that would normally be inserted.
		}		
	});

This code needs to happen anytime after validation.js is loaded.