I would advise to do anything that makes the input acceptable to the DB on the server. Not everybody has JavaScript enabled, and in any case client-side checks can be circumvented easily by malicious users. You should also read up on "SQL injection", and make sure that your application is not susceptible to it. Basically, any user input that finds its way into the DB should be treated with suspicion, and be verified. The
Security FAQ has some links to articles on this.