Benjamin Curtis

Speculations on Web Development

A Simple jQuery Validation Plugin

| Comments

I needed to do some client-side validation for my most recently-launched client project, Fretbase (for guitar enthusiasts), so I did a quick search for a validation plugin for jQuery. I found a couple of good ones, but none did exactly what I needed in the way that I wanted, so I ended up writing my first jQuery plugin. And, with a little help from the fantastic jQuery resources out there, it turned out to be easy.

So, here it is, my oh-so-simple validation plugin, with the one key feature that I had to have — being able to validate multiple fields with the same name:

It’s not especially pretty, but it gets the job done. And it’s called like so: $(‘some_selector’).validate(); … which just so happens to be the same syntax of the other, much more elegant jQuery validation plugin, but which doesn’t validate multiple fields with the same name. :)

Comments