Mootools Form.Validate is not firing events

570 views Asked by At

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/

1

There are 1 answers

1
Dimitar Christoff On BEST ANSWER

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);
    }
});