We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,414 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

tel number validation

hi there,
i have been asking this question every time.

public bool ValidateTelNo(string TelNo)
        {
            bool value = false;

            
                string rePhoneNumber = @"[1-9]\d{2}\s?\d{3}\d{4}$";
                string PhoneNoFormat = @"\([1-9]\d{2}\)\s?\d{3}\-\d{4}$";

                Regex re = new Regex(rePhoneNumber);
                Regex re1 = new Regex(PhoneNoFormat);

                if (re.IsMatch(TelNo) || (re1.IsMatch(TelNo)))
                    value = true;

                else
                    value = false;

           

            return value;
        }

in the above code can someone explain rePhoneNumber and PhoneNoFormat ?
what are the valeus that it takes in and what charaters (int string or special)

appriciate
thankx

3
Contributors
4
Replies
11 Hours
Discussion Span
2 Years Ago
Last Updated
5
Views
judithSampathwa
Posting Pro in Training
453 posts since May 2010
Reputation Points: 8
Solved Threads: 0
Skill Endorsements: 0

They are called regular expressions.
Plenty of this stuff to learn from on the net, example: http://gnosis.cx/publish/programming/regular_expressions.html
Success!

ddanbe
Industrious Poster
4,304 posts since Oct 2008
Reputation Points: 2,126
Solved Threads: 725
Skill Endorsements: 26

They are called regular expressions.
Plenty of this stuff to learn from on the net, example: http://gnosis.cx/publish/programming/regular_expressions.html
Success!

hey
how can i change the expression so the it is valid for (345) 456-2346 number and not for (3456) 456-4562

judithSampathwa
Posting Pro in Training
453 posts since May 2010
Reputation Points: 8
Solved Threads: 0
Skill Endorsements: 0

If you really, really need this stuff I can only advice you to study things you find on the net. Give you one more example: http://www.regexlab.com/en/regref.htm

ddanbe
Industrious Poster
4,304 posts since Oct 2008
Reputation Points: 2,126
Solved Threads: 725
Skill Endorsements: 26

Is this you buddy! - http://www.daniweb.com/forums/thread334504.html

i have been asking this question every time.

Asking same question multiple time is against the forum rules. Please tell us how this question is different than previous one.

__avd
Posting Genius (adatapost)
Moderator
8,736 posts since Oct 2008
Reputation Points: 2,141
Solved Threads: 1,262
Skill Endorsements: 50

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0863 seconds using 2.68MB