Re: validation in javascript
First, do the validation server-side. When you're satisfied with that, then you can do some validation client-side.
For that, learn JavaScript. Really learn it, not look at two small scripts and then come to a forum asking people to do it for you.
Re: validation in javascript
Validation in JavaScript should only complement validation on the server-side. Otherwise, if the user has JavaScript turned off, you're screwed.
Unless of course, you're submitting the form via JavaScript and only via JavaScript -- then the user can't do anything.
Re: validation in javascript
Sure. He can manually submit garbage to your server and corrupt your database.
Re: validation in javascript
There is no reliable way of ensuring where a HTTP request comes from - you must deal with whatever you get.