High-Performance Development - C#, VB, SQL, ASP.NET

Slogan Text

Form validation occurs at two levels in an ASP.NET web form: client-side and server-side. 

Client-Side Validation

Client-side validation occurs in the browser. When the user enters data into a field and tabs to the next field, or when the user clicks on the Submit button the client-side validation procedures are executed. The validation code (written in JavaScript) examines the field's contents and determines whether it is valid. If a field contains invalid data an error message is displayed and the form is not submittied to the server. When the user clicks on the Submit button the client-side validation code causes all validation checks to be performed for all fields which have validation controls. If any fields fail validation the form is not submitted to the server.
 
The value of client-side validation is: 1) the user immediately sees whether the data they entered is valid instead waiting for the browser to submit the form to the server, waiting for the server to perform validation and resend the form to the browser, and 2) simple field validation can be performed at this level. The disadvantages are: 1) validation involving multiple fields is more challenging or impossible to code for client-side execution.
 

Server-Side Validation

Server-side validation is performed as indicated on the server. When the user clicks on the Submit button all validation controls are executed. If validation controls are successfully the browser submits the form data to the server.  The ASP.NET code on the server examines the form data and determines whether it is valid. If the form data is invalid the ASP.NET code usually inserts an error message at the top of the web form telling the user about the problem.