Possible Duplicate:
Data input validation - Where? How much?
Given that I have a web application with a user facing form that will store information in a database (that will be used by other applications as well), it seems to me to be worthwhile to validate 3 times:
On the web client side via javascript to save postbacks to the server when the user enters bad data or forgets a field
On the server side because we can't trust the web client to have validated the data and saves calls to the database when the data is invalid
On the database side because this is the only way to ensure that the data stored in the database is valid.
On the one hand, this seems excessive and violates the DRY principle. On the other hand, the performance would be noticeably different if I had to submit the request, send it to the database and return an error generated by the database for bad or missing user information. What is a reasonable amount of validation?