Click here to Skip to main content
15,886,562 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
the problem is data is inserted less than 10 digit in database after applying such validation. how to solve it.



XML
<asp:TextBox runat="server" ID="txtMobile" MaxLength="12" />
                               <asp:RequiredFieldValidator ID="Requiredfieldvalidator2" runat="server" ControlToValidate="txtMobile" ValidationExpression="^[0-9]{10,12}$"
                                   ValidationGroup="entry"><img src="../images/erroricon.png" alt="error" /></asp:RequiredFieldValidator>
                               <ajaxToolKit:FilteredTextBoxExtender ID="fltMobile" runat="server" TargetControlID="txtMobile"
                                   FilterType="Numbers">
                               </ajaxToolKit:FilteredTextBoxExtender>
Posted

C#
/^.{10,}$/


use this one

or


C#
/[0-9a-zA-Z]{10,}/



here is the example


XML
<asp:TextBox id="txtUsername" runat="server" />

<asp:RegularExpressionValidator
id="RegularExpressionValidator1"
runat="server"
ErrorMessage="Field not valid!"
ControlToValidate="txtUsername"
ValidationExpression="[0-9a-zA-Z]{10,}" />


regards...:)
 
Share this answer
 
Comments
Mohd Arif Khan 13-Sep-13 2:51am    
Thanks :)
Dholakiya Ankit 13-Sep-13 2:52am    
welcome
ridoy 13-Sep-13 3:56am    
regex is always a good option,5ed!
Dholakiya Ankit 13-Sep-13 4:17am    
thanks redoy :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900