This post originated from an RSS feed registered with Ruby Buzz
by Guy Naor.
Original Post: Pre Validating Forms Using JS and Ajax
Feed Title: Famundo - The Dev Blog
Feed URL: http://devblog.famundo.com/xml/rss/feed.xml
Feed Description: A blog describing the development and related technologies involved in creating famundo.com - a family management sytem written using Ruby On Rails and postgres
Filling a long form on the web just to have it fail for all kind of reasons when I submit, always bothered me. I see it as unfriendly and inconvenient to start tracking down the failure, fill in the fields that weren't saved (like passwords) and submit it again. Sometimes ad-infinitum. Especially when the error is a unique login name, or other similar fields, that might require a few tries until you find a legal one.
We found a better solution for that. We run a few local validations using JavaScript, and for validation that require database access, or some calculation not easily done on the client, we just send an Ajax call into the server, and get back an error message if something is wrong.
Now when a user submit the form, in most cases there will be no errors generated, as it's all pre-validated.
If you need some sample code or help, let me know.