Previous | Home | Next |
It is used to validate the user input based on the validation expression.
Meta characters used to prepare the expression for single digit
Single digit | Description |
\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 |
It is used to specify the occurrence of the meta characters within the expression.
meta characters | Description | {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} |
Mode
It is used to specify the occurrence of the meta characters within the expression.
Mode | MinOccurrence | MaxOccurrence |
? | 0 | 1 |
. or * | 0 | Any |
+ | 1 | Any |
E.g.: \d{1, } <==> \d+
[ma+am] => accepts ‘madam, Malayalam ……
.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:
Previous | Home | Next |