Click here to Skip to main content
12,815,120 members (36,842 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# ASP.NET
Hello, Iam using a textbox which have mobile number,so I need to validate the number ,and I use requied field validator and regular expression validator ,also I use the espression(up to 10 digits) ,but the problem is if the mobile number have 10 zeros(0000000000) regular expression will not validate ,plz help to solve this..its urgent....
here is the code

                                           <asp:Label ID="lblMobile" runat="server" Text="Mobile Number" Font-Bold="True" ForeColor="Black"></asp:Label>
                                           <asp:TextBox runat="server" ID="txtMobileNumber" MaxLength="10" OnCopy="return false"
                                               OnPaste="return false" CssClass="popuptxtbox" onkeypress="return isNumberKey(event);"
                                               onkeyDown="checkTextAreaMaxLength(this,event,'11');" onblur="return valid(this,'restric_spec');"></asp:TextBox>
                                           <asp:RequiredFieldValidator ID="rfvMobileNumber" runat="server" ErrorMessage="*"
                                               ControlToValidate="txtMobileNumber" SetFocusOnError="true"></asp:RequiredFieldValidator>
                                           <asp:RegularExpressionValidator ID="rfvMobile" runat="server" ControlToValidate="txtMobileNumber"
                                               ErrorMessage="Minimum 10 digits" SetFocusOnError="True" ValidationExpression="^((\+)?(\d{2}[-]))?(\d{10}){1}?$"></asp:RegularExpressionValidator>
Posted 7-Nov-12 20:31pm
biswarup88 8-Nov-12 2:13am
did you google this topic? you'll get javascript to validate mobile no field.
faisal23 8-Nov-12 5:49am
use range validator and set min -0000000000 and max 9999999999 and type int

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Use this regex


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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170308.1 | Last Updated 9 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100