Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Parsley field validation event listener

I'm currently trying out Parsley.js, it works pretty good if you ask me however I have a few questions:

  1. What event should I listen to in order to append a glyphicon to the input's parent as soon as the input gets the class parsley-success or parsley-error class? The field:success and field-error events won't get fired without validate().

I tried this for example:

    $('.form-control').on('field:success', function () {
        if ($(this).parent().find('i').length) { //remove favicon if one's present
            $(this).parent().find('i').remove();
        }
        $(this).parent().append('<i class="fa fa-check-circle fa-lg fa-fw"></i>');
    });

but nothing happens when the input get's an error class assigned

  1. Im working with Ninja Forms in my Wordpress install, how would you guys assign the attributes to the inputs? This is not possible within the ui in the backend of NF. Currently I'm adding them with Javascript after the page has loaded but I wonder if this is the best way.