让magento的validate验证hidden field

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

但validation.js加载后,这段代码就会被执行。一下是我根据自己的需要改写的
Object.extend(Validation, {
isVisible : function(elm) {
while(elm.tagName != 'BODY') {
if(!$(elm).visible() && !$(elm).hasClassName('validate-must')) return false;
elm = elm.parentNode;
}
return true;
}
});

要想让这段代码执行,必须给要验证的field加validate-must。

<style type="text/css">
#advice-required-entry-consent_year{ position: absolute;}
</style>
作者:冯亮
         
能力有限,水平一般。如有错误,欢迎指正
原文地址:https://www.cnblogs.com/fengliang/p/5772508.html