Mootools Form.Validate 不会触发事件
我不知道为什么 Form.Validate
类在输入失败时不触发事件。这是我所做的一个简单测试:
HTML
<form id="IndicatorIndexForm" action="">
<input type="text" id="IndicatorKilometers" data-validators="minLength:10" name="data[Indicator][kilometers]"/>
<input type="submit" value="Valider" class="">
</form>
JS
var myForm = new Form.Validator($('IndicatorIndexForm'), {
onFormValidate: function(resp,form,e){
console.log('error');
},
elementFail: function(el,errors){
console.log('elementFail');
console.log(el);
console.log(errors);
},
elementValidate: function(resp,el,validator,is_warning){
console.log('elementValidate');
console.log(resp);
console.log(el);
console.log(validator);
console.log(is_warning);
}
});
但是当我提交表单时,在控制台中我只看到“错误”。如果我正确理解了文档,它还应该触发其他两个函数......我觉得我忘记了一些东西......有什么想法吗?
这是 jsfiddle http://jsfiddle.net/HJX3K/2/
I don't know why the Form.Validate
Class is not firing the events when an input fails. This is a simple test I've made:
HTML
<form id="IndicatorIndexForm" action="">
<input type="text" id="IndicatorKilometers" data-validators="minLength:10" name="data[Indicator][kilometers]"/>
<input type="submit" value="Valider" class="">
</form>
JS
var myForm = new Form.Validator($('IndicatorIndexForm'), {
onFormValidate: function(resp,form,e){
console.log('error');
},
elementFail: function(el,errors){
console.log('elementFail');
console.log(el);
console.log(errors);
},
elementValidate: function(resp,el,validator,is_warning){
console.log('elementValidate');
console.log(resp);
console.log(el);
console.log(validator);
console.log(is_warning);
}
});
but when I submit the form, in the console I only see "error". If I understood correctly the documentation, it should also fire the other two functions... I feel that I'm forgetting something.. any ideas?
here's the jsfiddle http://jsfiddle.net/HJX3K/2/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的。您缺少事件的
on
前缀:yes. you are missing
on
prefix for the events: