private void EmailAddresstextBox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { WebServiceUrltextBox.Focus(); e.Handled = true; } }
private void WebServiceUrltextBox_Leave(object sender, EventArgs e) { if (!string.IsNullOrEmpty(WebServiceUrltextBox.Text)) { string urlAddress = WebServiceUrltextBox.Text.Trim(); Regex mRegxExpression; Regex mRegxExpression1; mRegxExpression = new Regex(@"^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?$"); mRegxExpression1 = new Regex(@"^(www.)[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?$"); if ((!mRegxExpression.IsMatch(urlAddress)) && (!mRegxExpression1.IsMatch(urlAddress))) { MessageBox.Show("Please type your valid Url Address.", "MojoCRM", MessageBoxButtons.OK, MessageBoxIcon.Error); WebServiceUrltextBox.Clear(); WebServiceUrltextBox.Focus(); } } }