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

Append an element upon successful field validation #17

Closed
noahlh opened this issue Jan 21, 2013 · 4 comments
Closed

Append an element upon successful field validation #17

noahlh opened this issue Jan 21, 2013 · 4 comments

Comments

@noahlh
Copy link

noahlh commented Jan 21, 2013

Feature request:

It would be excellent if Parsley could be configured to append an element (div, ul, etc.) to the validated input in addition to / instead of changing the class to parsley-success

The use case: I'd like to show visual feedback in the form of a checkbox next to the form input instead of changing the actual input's appearance. Right now I have to make the checkbox appear as an offset background image, which is a bit hack-ey.

@guillaumepotier
Copy link
Owner

Ok. Seems right. I'll think about implementing it. I'll let you know

@noahlh
Copy link
Author

noahlh commented Jan 21, 2013

Thanks! This can probably be abstracted slightly to "trigger an action upon successful field validation" (where appending an element is one possible way.

FYI to those looking for an implementation now, I modified one line in the source:

this.errorClassHandler.removeClass( this.options.errorClass ).addClass( this.options.successClass )

and simply appended .trigger('validateSuccess') to call a custom validateSuccess jQuery event defined elsewhere. Works nicely but I'm sure there's a better way to integrate this into the library.

@guillaumepotier
Copy link
Owner

I've added a Parsley custom listener onFieldSuccess. See referenced commit.

If it is ok for you, please feel free to close this issue :)

Best

@noahlh
Copy link
Author

noahlh commented Jan 21, 2013

Looks awesome! Thanks!

@noahlh noahlh closed this as completed Jan 21, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants