private void CheckLoginInput() { var message = ""; bool isvalid = false; if (tbx1.Text != "") { isvalid = CheckUtil.Username(tbx1.Text); } else { btn2.IsEnabled = false; } if (PasswordBox1.Password == "") { isvalid = false; } else if (!CheckUtil.Password(PasswordBox1.Password)) { message += "\n密码太长或太短"; isvalid = false; } btn2.IsEnabled = isvalid; tbkMsg.Text = message; }
private void CheckInput() { var flag = true; if (tbxUser.Text == "") { flag = false; tbxUser.Background = new SolidColorBrush(Color.FromArgb(0x22, 0xff, 0xff, 0xff)); } else if (CheckUtil.Username(tbxUser.Text)) { tbxUser.Background = new SolidColorBrush(Color.FromArgb(0x22, 0xff, 0xff, 0xff)); } else { flag = false; tbxUser.Background = new SolidColorBrush(Color.FromRgb(0xff, 0x66, 0x33)); } if (pwb1.Password == "") { flag = false; pwb1.Background = new SolidColorBrush(Color.FromArgb(0x22, 0xff, 0xff, 0xff)); } else if (CheckUtil.Password(pwb1.Password)) { pwb1.Background = new SolidColorBrush(Color.FromArgb(0x22, 0xff, 0xff, 0xff)); } else { flag = false; pwb1.Background = new SolidColorBrush(Color.FromRgb(0xff, 0x66, 0x00)); } if (flag) { gridLogin.Background = Brushes.DeepSkyBlue; btnLogin.IsEnabled = true; } else { gridLogin.Background = new SolidColorBrush(Color.FromRgb(0xaa, 0xaa, 0xaa)); btnLogin.IsEnabled = false; } isInputValid = flag; }