Live data from Hacker News

Parsley.js: never write a single JavaScript line to validate your forms

parsleyjs.org

31–40 of 80 posts

Re: Parsley.js: never write a single JavaScript line to validate your forms

#32
post #25

Earlier quoted context omitted.

For one of my new projects, that is precisely what I am doing - making it possible to define complicated validation rules in a simple manner (and lots more). Would there be interest if we open-source it?

Quite possibly. Though I'm not sure how much this could be generalised since complex validation rules are effectively computer programs in themselves. Not sure what your approach to this problem is, but perhaps one way to do it would be a validation engine that is inherently functional by design. Of course, ideally it should be something that can plug in to popular web frameworks easily.

Data binding solves this generically. It allows you to build state machine trivially Stuff like angular and ember do this amazingly well though it would be nice to have a nice standalone library. (no idea if one exists)

Re: Parsley.js: never write a single JavaScript line to validate your forms

#33
post #3

Speaking with my security hat on: This is a really nice library, but you also do the same validations server side right?

Client side and server side validations need (should!) not be the same — i'd make serverside validation stricter. Client side is for eliminating honest mistakes not preflighting exploits.

Could you give an off the top of your head example?

Re: Parsley.js: never write a single JavaScript line to validate your forms

#36
Has anyone had any experience where adding or removing client-side validation has affected conversion?

Other comments talked about client-side validation being mainly for UX and user convenience. But I'm wondering if it has a noticeable effect on whether or not people actually submit the form all the way to completion (i.e. no errors).

I made a tool that I have server-side form validation. I found that saving the invalid input so that I could examine it later was extremely valuable in understanding what people were entering, so that I could make the tool smarter. A good example is like with Parsley's demo where it requires http:// for the website URL. After seeing that people tried to enter URLs without http://, I knew I could change my code to automatically infer it. http:// is obvious, but a lot of times, people will surprise you. I don't have stats, but presumably this kind of change increases conversion. I realize this anecdote is a different effect than what I'm asking about client-side validation.

Re: Parsley.js: never write a single JavaScript line to validate your forms

#37
The url validation seems a bit strict, requiring "http:// at the start. No one types that these days, and I think in practice it might be a real roadblock for less computer literate users. I notice also that "ftp://" is valid, but not other protocols like, say, "afp://" or "git://".

Other than that, great job! I'm actually really looking forward to using this in my next project - form validation is usually such a pain.

Re: Parsley.js: never write a single JavaScript line to validate your forms

#38
post #9

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,…

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…

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 validate your forms

#39
This is neat.

A couple of points:

1- Client side validation is easy to circumvent. If you use this you have to make sure it is for UI only and that the real validation happens server side.

2- Using regex for email validation is fraught with issues. Probably the most salient one is that there are a million expressions out there. People run a quick google search, grab one and move on without knowing what they just plugged into their code. This particular tool will, for example, pass "m@apple.comm" as valid.

Other than that, I am sure this is a great time saver.

Post reply on HN