Ejemplo n.º 1
0
 private void PhoneTxt3_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         EmailTxt.Focus();
         e.Handled          = true;
         e.SuppressKeyPress = true;
     }
 }
Ejemplo n.º 2
0
        protected void TextBox1_TextChanged(object sender, EventArgs e) //Check if email is valid.
        {
            RegexStringValidator emailValid = new RegexStringValidator(regexEmail);

            isValidEmail = false;
            try
            {
                emailValid.Validate(EmailTxt.Text);
                isValidEmail = true;
            }
            catch (ArgumentException)
            {
                isValidEmail = false;
            }
            if (isValidEmail == true)
            {
                SqlConnection myConn = GetConnection();
                myConn.Open();
                bool           alreadyHaveAccount = false;
                string         sqlStr             = "select Email from [User];";
                SqlCommand     myCmd = new SqlCommand(sqlStr, myConn);
                SqlDataAdapter da    = new SqlDataAdapter(myCmd);
                DataSet        ds    = new DataSet();
                da.Fill(ds);
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    if (String.Compare(EmailTxt.Text, ds.Tables[0].Rows[i]["Email"].ToString(), 0) == 0)
                    {
                        alreadyHaveAccount = true;
                    }
                }
                if (alreadyHaveAccount == true)
                {
                    EmailTxt.BorderColor = System.Drawing.Color.Red;
                    EmailHint.Text       = "You already have an account!";
                    EmailHint.Visible    = true;
                    EmailTxt.Focus();
                }
                else
                {
                    EmailTxt.BorderColor = System.Drawing.Color.Black;
                    EmailHint.Text       = "";
                    EmailHint.Visible    = false;
                }
                da.Dispose();
                ds.Dispose();
                myConn.Close();
            }
            else
            {
                EmailTxt.BorderColor = System.Drawing.Color.Red;
                EmailHint.Text       = "Please enter a valid email!";
                EmailHint.Visible    = true;
                EmailTxt.Focus();
            }
        }
Ejemplo n.º 3
0
 private void PhoneTxt3_TextChanged(object sender, EventArgs e)
 {
     if (Loaded)
     {
         HandlePhoneNumChange();
         if (PhoneTxt3.TextLength == 4)
         {
             EmailTxt.Focus();
         }
     }
 }
Ejemplo n.º 4
0
        private void EmailTxt_Leave(object sender, EventArgs e)
        {
            Regex mRegxExpression;

            if (EmailTxt.Text.Trim() != string.Empty)
            {
                mRegxExpression = new Regex(@"^([a-zA-Z0-9_\-])([a-zA-Z0-9_\-\.]*)@(\[((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}|((([a-zA-Z0-9\-]+)\.)+))([a-zA-Z]{2,}|(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\])$");

                if (!mRegxExpression.IsMatch(EmailTxt.Text.Trim()))
                {
                    MessageBox.Show("E-mail address format is not correct.", "MojoCRM", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    EmailTxt.Focus();
                }
            }
        }