Symfony JsFormValidatorBundle run validation on custom event

我的未来我决定 提交于 2019-12-11 12:10:58

问题


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

来源:https://stackoverflow.com/questions/25439917/symfony-jsformvalidatorbundle-run-validation-on-custom-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!