-->

Symfony的JsFormValidatorBundle自定义事件上运行验证(Symfony Js

2019-09-30 08:07发布

我使用JsFormValidatorBundle包和非常喜欢它。 验证提交的作品被点击的时候,但我想验证,以场变化后立即工作,而无需提交表单

我想下面运行自定义事件验证:

$('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);
                    }
                }
            });

我得到这个错误:遗漏的类型错误:无法未定义fp_js_validator.js的读取属性“变形金刚”:536

我试图用完全相同的代码作为https://github.com/formapro/JsFormValidatorBundle/blob/master/Resources/doc/3_12.md可惜得到同样的错误

文章来源: Symfony JsFormValidatorBundle run validation on custom event