Mootools Form.Validate is not firing events
-
28-10-2019 - |
سؤال
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 correclty the doc, it should also fire the other two functions... I feel that I'm forgetting something.. any ideas?
thanks in advance
here's the jsfiddle http://jsfiddle.net/HJX3K/2/
المحلول
yes. you are missing on
prefix for the events:
var myForm = new Form.Validator($('IndicatorIndexForm'), {
onFormValidate: function(resp,form,e){
console.log('error');
},
onElementFail: function(el,errors){
console.log('elementFail');
console.log(el);
console.log(errors);
},
onElementValidate: function(resp,el,validator,is_warning){
console.log('elementValidate');
console.log(resp);
console.log(el);
console.log(validator);
console.log(is_warning);
}
});
لا تنتمي إلى StackOverflow