Symfony JsFormValidatorBundle run validation on cu

2019-08-04 08:54发布

I am using JsFormValidatorBundle bundle and liked it very much. Validation works when submit is clicked but I want validation to work immediately after field change without submitting the form

I want to run validation on custom event as below:

$('form')
                .find('input, select, textarea')
                .change(function(){
                    $(this).jsFormValidator('validate');
                })
                .jsFormValidator({
                showErrors: function(errors, sourceId) {
                    var list = $(this).next('span.help-block');
                    list.find('.' + sourceId).remove();
                    if(errors.length){
                        $(this).closest('div.mgnBtm20').addClass('badData');
            $(this).closest('div.mgnBtm20').removeClass('goodData');
                    }else{
                        $(this).closest('div.mgnBtm20').removeClass('badData');
                        $(this).closest('div.mgnBtm20').addClass('goodData');
                    }
                    for (var i in errors) {
                        var li = $('<span></span>', {
                            'class': sourceId,
                            'text': errors[i]
                        });
                        list.append(li);
                    }
                }
            });

and I get this error: Uncaught TypeError: Cannot read property 'transformers' of undefined fp_js_validator.js:536

I tried to use exactly same code as in https://github.com/formapro/JsFormValidatorBundle/blob/master/Resources/doc/3_12.md but unfortunately get the same error

0条回答
登录 后发表回答