Hacker News new | ask | show | jobs
by evx 5141 days ago
Neat. But I don't understand why you used strings as part of the validation?

The "min_length(6)|required" isn't actual javascript code is it?

Would passing an object be better?

For example,

userForm.addValidation("username", "min_length(6)|required");

Becomes,

userForm.addValidation("username", {min_length:6, required:true});

Did I misunderstand something?

3 comments

Hey,

Thank you so much for this. I've no idea why I didn't think of this initially - but I've now rewritten the plugin to do this instead. Hope you like it - and thanks again!

Jack

Great job! Gotta love the responsiveness. I hope you keep making it better.
This change appears to have been pushed already. Can't fault the responsiveness!
{yes: 'please'}
I modelled it off the way CodeIgniter validations as I always liked how they worked - but thinking about it this is a great idea - going to make this change sometime soon :)

Thanks!