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

No front-end validation #141

Open
Xananax opened this issue Aug 30, 2014 · 1 comment
Open

No front-end validation #141

Xananax opened this issue Aug 30, 2014 · 1 comment

Comments

@Xananax
Copy link

Xananax commented Aug 30, 2014

Although the readme specifies that one of the goals is to use the same validation on the server side and on the front-end, I couldn't find anything to accomplish this.

I whipped up my own method, see here:
https://gist.github.com/Xananax/7178b559ba783a97b0a0

Two questions:

  1. Is there already a system in place and I've just missed it?
  2. I'd like some code review on what I've done, and if there is anything simpler, because it does seem like a lot of boilerplate.
@ljharb
Copy link
Collaborator

ljharb commented Aug 30, 2014

Just like on the backend, where you'd construct a form object, and then call .bind and .handle on it, you can do exactly the same in the frontend.

You definitely shouldn't need all those loops and vars to do it - you should be able to just pass something like $('form').serialize or $('form') or $('form').get(0) into handle.

Currently, it only accepts an object, so you'd need to build one yourself by iterating (not looping) over $('form').serializeArray().

I'll leave this open since forms should in its handle method certainly accept both a jQuery object, and a <form> HTMLElement.

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