It is used to validate the user input based on the validation expression.
Meta characters used to prepare the expression for single digit
\d | Accepts a single digit |
/D | Accepts a single character |
\w | Accepts any character other than a white space (spacebar) |
\s | Accepts a space |
[A-Za-z] | Accepts upper or lower case characters |
[0-9] | Accepts a numerical value |
^[0-9] | Accepts any characters other than numeric value |
Occurrences:
It is used to specify the occurrence of the meta characters within the expression.
{number} | Accepts the input if the length of the expression is equal to the specified number E.g.: \d{5} à accepts 5 digits number |
{Minnumber, } | Accepts the input if the length after expression is greater than or equal to the specified Minnumber. E.g: [A-Za-z0-9_]{6, } |
{Minnumber, Maxnumber} | Accepts the input if the length of the expression is between the specified range. e.g.: \D{6,8} |
Modes:
It is used to specify the occurrence of the meta characters within the expression.
Mode | MinOccurrence | MaxOccurrence |
? | 0 | 1 |
. or * | 0 | Any |
+ | 1 | Any |
.ASPX CODE
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="plese enter email ID" ToolTip="plese Enter email id" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator> |
Output:
No comments:
Post a Comment