Exemplo n.º 1
0
        private bool CheckInfo()
        {
            StringBuilder tip = new StringBuilder();

            if (textBoxRealName.Text.Length == 0)
            {
                tip.Append("真实姓名不得为空\r\n");
            }
            if (textBoxAddress.Text.Length == 0)
            {
                tip.Append("住址不得为空\r\n");
            }
            if (textBoxPhoneNumber.Text.Length == 0)
            {
                tip.Append("手机号码不得为空\r\n");
            }
            if (textBoxRealName.Text.Length == 0)
            {
                tip.Append("电子邮箱不得为空\r\n");
            }
            if (textBoxRealName.Text.Length > 50)
            {
                tip.Append("真实姓名不得超过50个字符\r\n");
            }
            if (textBoxAddress.Text.Length > 100)
            {
                tip.Append("住址不得超过100个字符\r\n");
            }
            if (textBoxEmailAddress.Text.Length > 100)
            {
                tip.Append("电子邮箱不得超过100个字符\r\n");
            }
            if (!StringChecker.IsEmailAddress(textBoxEmailAddress.Text))
            {
                tip.Append("电子邮箱格式不正确\r\n");
            }
            if (!StringChecker.IsPhoneNumber(textBoxPhoneNumber.Text))
            {
                tip.Append("手机号码格式不正确\r\n");
            }

            if (tip.Length == 0)
            {
                return(true);
            }
            else
            {
                MessageBox.Show(tip.ToString());
                return(false);
            }
        }
Exemplo n.º 2
0
 private void textBoxEmailAddress_TextChanged(object sender, EventArgs e)
 {
     if (textBoxEmailAddress.Text.Length == 0)
     {
         labelTipForEmailAddress.Text = "*电子邮箱地址不能为空";
         _isEmailAddressValid         = false;
     }
     else if (!StringChecker.IsEmailAddress(textBoxEmailAddress.Text))
     {
         labelTipForEmailAddress.Text = "*电子邮箱地址格式不正确";
         _isEmailAddressValid         = false;
     }
     else
     {
         labelTipForEmailAddress.Text = "";
         _isEmailAddressValid         = true;
         _emailAddress = textBoxEmailAddress.Text;
     }
 }