Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2005

Tip: Looking for answers? Try searching our database.

Help with regular expression

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joe - 20 Jul 2005 20:22 GMT
Hi,

I am stuggling with building a regular expression that would allow only 0-9,
+, -,_, space, (, ). Can someone guide me. This is for validating phone using
JavaScript in my asp page.

Thanks for you time,

Joe
Dave Fancher - 20 Jul 2005 20:32 GMT
Don't recreate the wheel.  Search http://www.regexlib.com/Default.aspx.  
You're bound to find what you're looking for.

HTH
----
http://www.davefancher.com

> Hi,
>
[quoted text clipped - 5 lines]
>
> Joe
Irfan Afzal - 26 Jul 2005 08:24 GMT
hello
i think this code will help. U have to change the code a little bit
according to ur situation. in my case if the phone no. is valid then it will
return true. u can send return the validated phone no or error message.
Note: in this function i have use a string variavble ErrorMessage which is
member of the class. You have to handle it urself.

for any more help you can contact me via emal ---> cuirfan@hotmail.com

public bool Validity( string PhoneNo)
{
    bool flag = false;
    if( PhoneNo[0] >= '0' && PhoneNo[0] <= '9' || (PhoneNo[0] == '+') )
    {
        for(int i = 1; i < PhoneNo.Length; i++)
        {
            if( (PhoneNo[i] >= '0' && PhoneNo[i] <= '9') || (PhoneNo[i] == '_') ||
(PhoneNo[i] == '-') || (PhoneNo[i] == ' ') )
                flag = true;
            else
            {
                this.ErrorMessage = "The character \"" + email[i] + "\" is not allowed
in the PhoneNo";
                flag = false;
                break;
            }
        }
    }
    else
    {
        this.ErrorMessage = "First character must be between 0-9 or it may be + ";
        flag = false;
    }
    return flag;
}

> Hi,
>
[quoted text clipped - 5 lines]
>
> Joe

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.