Tips Tricks Samples

Three Javascript Form Validation Tips

I'm in the process of putting together a new web form and have picked up a few bits and pieces which you may find useful:

The really easy field validation with Prototype script by Andrew Tetlaw is, indeed really easy to implement. But beyond that it's also simple to extend to add your own validation rules, be they simple or complex. I think this is going to become my default front-end validation script until I find a better one.

One of the changes I needed to make to the script was to add a test for a specific number format, to allow comma separation at thousands but disallow decimal points (and vice versa for European users). Now I really don't understand Regex very well at all. But I did manage to find an OS X Widget devoted to testing Regex expressions, I recommend it heartily. And it allowed me to write this expression to do my validation:
/^[0-9\,\-\+\(\)\ ]+$/