Sometimes we have a need to apply Regular Field Validations(validations for format of entry to be filled in Text Box) in our Text Box. The properties which need to be set for Regular Field Validations are as follows.
Summary
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ErrorMessage="Invalid Format" ControlToValidate="txt_emp_name" ForeColor="Red" ValidationExpression="^[a-zA-Z]+$ Display="Dynamic"
SetFocusOnError="True"
ValidationGroup="sub"></asp:RegularExpressionValidator>
Terms Used:
ErrorMessage: Message to be displayed to show
error.
SetFocusOnError: So that cursor remains on the textbox which has
error.
ValidationGroup: It should be same as validation of button on
whose click event action on the textbox
will be take.
ControlToValidate: Name
of Textbox on which validation is to be applied.
ForeColor: Color
in which error is displayed.
Summary
In this article I try to expose the Regular Field Validation. I hope after reading this article you will be able to use this trick in your code. I would like to have feedback from my blog readers. Please post your feedback, question, or comments about this article.