Website Validiting in C#

Posted by imomins on May 16, 2011 at 8:37 AM

if (txtWebsite.Text != "")

                {

                    if (!isWeb(txtWebsite.Text))

                    {

                        MessageBox.Show("Please Enter Valid Website Name");

                        txtWebsite.Focus();

                        txtWebsite.SelectAll();

                    }

                    else

                    {

                        txtEmail.Focus();

                        txtEmail.SelectAll();

                    }

                }

                else

                {

                    txtEmail.Focus();

                    txtEmail.SelectAll();

                }

 

 

 

 

public static bool isWeb(string inputWebsitel)

        {

            return Regex.IsMatch(inputWebsitel,@"^(((ht|f)tp(s?))\://)?(www.|[a-zA-Z].)[a-zA-Z0-9\-\.]+\.(com|edu|gov|mil|net|org|biz|info|name|museum|us|ca|uk)(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\;\?\'\\\+&%\$#\=~_\-]+))*$");

 

        }

 


Categories: Personal, C#, Critical

Post a Comment

Oops!

Oops, you forgot something.

Oops!

The words you entered did not match the given text. Please try again.

You must be a member to comment on this page. Sign In or Register

0 Comments