hi! i have a form to enter data i want to put validations in the text boxes and prompt the user if he/she enters the wrong data
i want to put validations for
phone number
Date of birth
email
i tried using regex but it says that i am missing a reference
do i have to add references? if so what header should i import?

System.Text.RegularExpressions.Regex

hey it still doesnt work even though i used the header my code is

String rePhoneNumber = @"\([1-9]\d{3}\)\s?\d{3}\-\d{4}$";
            Regex re = new Regex(rePhoneNumber);

            if (re.IsMatch(textBox1.Text))
                MessageBox.Show("valid phone number");
            else
                MessageBox.Show("Phone Number Must Be Entered As: (555) 555-1234");

Errors are
Error 1 The type or namespace name 'Regex' could not be found (are you missing a using directive or an assembly reference?) D:\HDProject\GOGREEN\GOGREEN\SalesPerson.cs 48 13 GOGREEN
and

Error 2 The type or namespace name 'Regex' could not be found (are you missing a using directive or an assembly reference?) D:\HDProject\GOGREEN\GOGREEN\SalesPerson.cs 48 28 GOGREEN

Header For Regular Expression in C# is

using System.Text.RegularExpressions;

Thanks it worked!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.