forms icon indicating copy to clipboard operation
forms copied to clipboard

No front-end validation

Open Xananax opened this issue 11 years ago • 1 comments

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.

Xananax avatar Aug 30 '14 12:08 Xananax

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.

ljharb avatar Aug 30 '14 16:08 ljharb