Generic Form Validation Routine

Generic Form Validation Routine is yet another useful, unobtrusive, progressive enhancement ECMAScript technique from Gez Lemon. No inline scripts to be seen.

Comments

1. April 28, 2005 by Woolly Mittens

Here's another example of this I made some time ago. The classname of the elements determines the regular expression used for validation.

Offcourse, validation should also always be done server side to make sure.

className based regexp form validation

2. April 28, 2005 by David Carrington

I prefer having an extra field (suprisingly called "validation") that holds all of the validation information for the form. The field should be a disabled and hidden input, which the ECMAScript can access to give an instant response to anything going wrong.

I tend not to like popups, so my versions also creates an error message in a at the top of the page. Meanwhile, the invalid fields are also highlighted in red (with a .invalid class name).

3. April 28, 2005 by Milan Negovan

Good technique.

We all learned in ASP.NET that client-side validation is icing on the cake; while server-side validation is a must.

At my previous job about 50% of all errors occured because some developers never bothered to check length and integrity of data they were storing in the database.

4. April 28, 2005 by Fatalis Erratum

The link is currently returning 503 (Service Unavailable).

5. April 28, 2005 by Justin Perkins

That Juicy Studio site is down quite frequently. You get to learn that from ASP.NET too :)

6. April 29, 2005 by Roger Johansson

Yeah I've noticed intermittent problems with accessing the site. It usually only lasts a minute or so.

7. April 29, 2005 by Paul Solecki

Quite a nice method. I started toying with a naming convention for fields with validation strings e.g. INTfieldname. When data got passed back my PHP it knew what to validate without having to hardwire each form. I guess it'd also work in JavaScript too but the field names are a bit messy :)

I don't usually mess with client side validation but when it's nice and easy you may as well!

8. May 24, 2005 by Stuart Young

Um, that link to Juicy Studio is now a 404 error. It's only a month since this blog entry? Does the web realy move this fast?

9. May 24, 2005 by Roger Johansson

Juicy Studio has been having hosting problems and was forced to move to a new domain and host. That probably explains the 404 error. Hopefully it is only temporary.

Sorry, comments are closed for this post.

Information, sponsorship, and externals

About the author

Roger Johansson is a Swedish web professional specialising in web standards, accessibility, and usability. More about me and this site.

Subscribe

Looking for web hosting?

Try DreamHost!

Use the promo code 456BEREASTREET3 to save USD 20 when you sign up!

Latest articles

Validation statistics from Nikita the Spider Comments off
An analysis of the sites crawled by the bulk validation tool Nikita the Spider during March 2008.
Authentic Jobs API and Affiliates program Comments off
The Authentic Jobs job listing service now has a public API and an affiliate program.
What does Acid3 mean to you and me? Comments off
Opera and Apple have announced that their web browsers pass the Acid3 Browser Test, but how will that help web designers and developers?
Designing Web Navigation (Book review) Comments off
Learn the fundamentals of navigation design and design better navigation systems for large and small sites as well as for web based applications.
DOMAssistant bundle for TextMate Comments off
To save keystrokes and speed up development I have created a DOMAssistant bundle for TextMate.
First impressions of Internet Explorer 8 Beta 1 Comments off
My impressions after trying out Internet Explorer 8 Beta 1 for a couple of days.

More articles

Favourites, here and elsewhere

Affiliation

  • NetRelations
  • Kaffesnobben
  • Dagens recept
  • 9rules network member

Support this site

Show your support by buying a book or two from SitePoint or getting me something from my Amazon Wish List.