Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function for custom event doesn't work #147

Open
isabelle112 opened this issue Apr 19, 2018 · 2 comments
Open

Function for custom event doesn't work #147

isabelle112 opened this issue Apr 19, 2018 · 2 comments
Labels

Comments

@isabelle112
Copy link

isabelle112 commented Apr 19, 2018

Hi,

I am using the bundle for validating my symfony form. Everything works fine but now I need to validate at a custom event. I've tried to use the code from the readme file number 12, but I get the error, that

$('form').find('input[type=text], textarea') .blur(function(){ // Run validation for this field $(this).jsFormValidator('validate'); }).focus(function() { // Reset markers when focus on a field $(this).removeClass('error'); $(this).removeClass('ready'); }).jsFormValidator({'showErrors': function(errors){if (errors.length) { $(this).removeClass('ready'); $(this).addClass('error'); } else { $(this).removeClass('error'); $(this).addClass('ready'); }} }); this part of the code "is not a function". if I remove the last part from jsFormValidator({... I don't get an error.

Could you please help me, where the issue is?

Thanks!

@zinoviosDev
Copy link

Hi,
I'm fighting with the same problem. Did you find some workarounds since your post ?

On my side, I'm observing that jsFormValidator function is defined in this little code:
if(window.jQuery) { (function($) { $.fn.jsFormValidator = function(method) { if (!method) { return FpJsFormValidator.customizeMethods.get.apply($.makeArray(this), arguments); } else if (typeof method === 'object') { return $(FpJsFormValidator.customizeMethods.init.apply($.makeArray(this), arguments)); } else if (FpJsFormValidator.customizeMethods[method]) { return FpJsFormValidator.customizeMethods[method].apply($.makeArray(this), Array.prototype.slice.call(arguments, 1)); } else { $.error('Method ' + method + ' does not exist'); return this; } }; })(jQuery); }
I've just copied the definition of the function in my js code just before doing treatment on customized events with $('form').find('input[type=text], textarea') .blur(function(){ // Run validation for this field $(this).jsFormValidator('validate') and that worked for one form but not the other one (I have 2 modal forms in my page). Maybe that could help in your case.

@isabelle112
Copy link
Author

isabelle112 commented May 30, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants