RequiredFieldValidator Example in asp .net
Validations are the most important part of websites and software. By using validations we can restrict users to enter any Invalid data into your database. There are many validation techniques available do validate form data like JQUERY validations, server side validations. In Asp .Net microsoft has provided us great validation controls. In this series of articles we will explore validation controls provided by microsoft.
In this article we will see how to use RequiredFieldvalidator in asp .net. We can use required field validator to ensure that user cannot enter blank data.
Step1: Create TextBox control, Validation Control and Button.
Step2: Use ErrorMessage property of RequiredFieldValidator and enter message you want to display.
Step3: Use ControlToValidate property of RequiredFieldValidator and enter id of TextBox which you want to validate.
Step4: Use ForeColor property of RequiredFieldValidator and enter name of the color you want to use.