How do I show what validation errors Parsley.js has found?

Phil Gyford picture Phil Gyford · Dec 16, 2014 · Viewed 7.2k times · Source

I'm using Parsley.js to validate part of a form like in this example. However, the validate() method always returns false, even when that piece of form should validate.

No error messages are displaying, and I want to see what it is that's failed validation.

I can't see a way to get Parsley to simply return all the errors found, so I can see them in the console. Have I missed something obvious?

Answer

Ivan Uemlianin picture Ivan Uemlianin · Jan 7, 2016

You can use something like this:

window.Parsley.on('field:error', function() {
  // This global callback will be called for any field that fails validation.
  console.log('Validation failed for: ', this.$element);
});

from http://parsleyjs.org/doc/index.html#events