Database interaction occurs Server Side.
JavaScript is executed Client Side.
You cannot write JavaScript validations that are execute
when a database is being updated.
You can, however, validate that the data the user provided in the web page before the data is sent to the server using JavaScript.
Since it is easy to get around client-side validation, you should also validate the data Before you update the database with the data the user provided.
So, you need to do validation in 2 places: client-side (with JavaScript) and server-side.
You can use pre-baked ASP.NET controls like the
RequiredFieldVa lidator control, or the
CustomValidator control, or any other Validator control...
Please take a look at:
Validating in ASP.NET
-Frinny