如何验证我的表单并在链接点击事件中提交?我的代码如下:
new Element('a',{
'html': "To cart",
'class': 'shop_add',
'href': 'javascript:void(0)',
events: {
click: function(e){
new Form.Validator(product_details_sub_container, {
stopOnFailure: true,
useTitles: true,
errorPrefix: "",
ignoreHidden : false,
onFormValidate: function(passed, form, event) {
console.log("Validation status: " + passed);
if (passed) {
event.stop();
...ajax request is here
}
}
});
}
}
}).inject(container);
为什么 onFormValidate() 函数不起作用?谢谢!