Now you will see the browser posting back to the server, but the result will be the same - the validator still works!
Right now, the button does nothing, besides posting back if the page is valid.
The first name is required, but when I run the program, and I leave the First Name field blank, I still get the page that thanks me for filling out the survey.
"Objects" do not have an "id" - do you mean names for variables? Or, perhaps you mean the "id" attribute of an element? Do you mean any elements on the page with the same id will break validation?
We will change this by adding an onclick event to it: As you will notice, we check whether or not the page is valid, before we do anything.
This is very important, since this code WILL be reached if the clientside validation is not used, for some reason.
(34 printed pages) Introduction Looking at Validation The Required Field Validator Control The Compare Validator Control The Range Validator Control The Regular Expression Validator Control The Custom Validator Control The Validation Summary Control Conclusion In your studies of ASP.Anthony Moore Microsoft Corporation July 2000 Updated March 2002 Summary: Provides a brief overview of the validation framework in ASP.NET and walks through an example of adding validation to a page.DTHML and scripting languages improve things somewhat.It is possible to provide the user with immediate feedback on bad input and to prevent them from posting a page until it has been corrected.Validation server controls are a series of controls that help you validate the data that the user enters into the other controls that are provided with ASP. They determine whether the form can be processed based upon the rules that you define in the validation server controls.