Pages

Friday, May 8, 2009

Required Field Validation Control in ASP.NET

Required Field Validator:

Suppose in a form,there are some fields which have to be mandatory to the user i.e the user should fill in those fields compulsorily.In that case we can use Required field validator.

Lets say there is a textbox for user to enter his name with id "txtName" and this is mandatory field,then a required field validation control can be used like below:

The required field validator has attribute "ControlToValidate" which is set to the id of the control.If the user does not enter value in the textbox,then an error message "Name is required" is shown to the user.


No comments: