News for hackers. Stuff that matters.
Re:Parsley.js: never write a single JavaScript line to valid... by truebosko on Sunday January 20, 2013 @09:26AM (#5086977)
I suppose this is more suited to when your models and schema are also defined on the client side?

Having just hit this situation (validating a form client-side), I found the best solution was to transport the form schema from the server (because I use Django, I can easily whip up a ModelForm), then push that into a simple Javascript Form object which renders the schema and adds validation. Maybe there's better ways, but that's what worked for me. Curious what others have done .. :-)

Re:Parsley.js: never write a single JavaScript line to valid... by pestaa on Sunday January 20, 2013 @09:42AM (#5087036)
Nice to have a full-blown client-side equivalent of schema definitions and validation rules, but for most of my forms, I just add it quickly and dirty. Sometimes it feels bad, but most web toolkits treat JavaScript as a second-class citizen and not an integrated part of its core (and no, throwing in a jQuery does not count).

Yii framework (PHP) supports validation through Ajax (serializes the form, sends for regular server-side validation and displays the errors on the form). A godsend if your form does not change, and impossible to work with if it is dynamic (consider batch entries with "Add line" features, etc.).

I haven't seen a seamless integration on this higher level.

Re:Parsley.js: never write a single JavaScript line to valid... by phpnode on Sunday January 20, 2013 @01:41PM (#5087686)
Yii can also do client side validation (without an ajax call) for most of its built in validation rules.
Re:Parsley.js: never write a single JavaScript line to valid... by insin on Sunday January 20, 2013 @11:01AM (#5087228)
Is the form definition-to-JavaScript code open source, by any chance?

I ported django.forms to JavaScript so I could use it with Node.js, but it also runs on the client: https://github.com/insin/newforms

Could be useful to plug the two together.

Re:Parsley.js: never write a single JavaScript line to valid... by jva on Sunday January 20, 2013 @09:38AM (#5087020)
With Rails I did come up with a similar solution to Parley.js. Just add a helper that renders the needed data-attributes and you're done.

Your solution sounds nice for single page apps.