Be carefull about on change - there is a funny issue with it on IE
Let say you have the following code:
<input name="x" onchange="this.value=3;">
If you type, for example 2 in this field, than click somewhere else, onchange fires, and changes it to 3. So, you go to that field again, and delete this three, and type something, and click somewhere else - you would expect your onchange to fire. It will, for everything except 2 !!!. Somewhere deep inside IE doesn't take changes your script made into account to define does the value chnged or not.
By the way, personally, I would prefer to do validation server side.
Here is a reason - let say somebody out of "curiosity" sets values on your form directly using javascript - what would your server do?
If you server does not check what goes to a database, it could be a security hole. And if you validate it on server - why would you do it twice?
Simple example:
Let say you have a field named "City".
On server side you create a SQL like this:
"Select * from users where city='" + city + "'";
Now, user types in browser addres bar:
javascript:document.forms[0].City.value="';delete from users where city like '%";document.forms[0].submit();
Your query will look like:
"Select * from users where city='';delete * from users where city like '%'"
[ February 16, 2004: Message edited by: Yuriy Fuksenko ]