Exemple #1
0
 private void Password2_GotFocus(object sender, RoutedEventArgs e)
 {
     Password.Visibility = System.Windows.Visibility.Visible;
     Password2.Focus();
     Password2.Visibility = System.Windows.Visibility.Collapsed;
     Password2.Focus();
 }
        private void Register_Click(object sender, RoutedEventArgs e)
        {
            strUsername  = Username.Text;
            strPassword  = Password.Password;
            strPassword2 = Password2.Password;
            strEmail     = Email.Text;
            if (string.IsNullOrEmpty(strUsername))
            {
                MessageBox.Show("请输入用户名!");
                Username.Focus();
                return;
            }
            else if (string.IsNullOrEmpty(strPassword))
            {
                MessageBox.Show("请输入密码!");
                Password.Focus();
                return;
            }
            else if (!strPassword.Equals(strPassword2))
            {
                MessageBox.Show("两次密码不一致!,请重输。");
                Password2.Focus();
                return;
            }
            else if (!Regex.IsMatch(strPassword, regex))
            {
                MessageBox.Show("请输入规范的密码,密码长度6-20位。");
                Password.Focus();
                return;
            }
            else
            {
                MessageBox.Show("恭喜您注册成功!" + '\n' + "您的信息如下:" + '\n' + strUsername + '\n' + strGender + '\n' + strPassword);

                this.Close();
            }
        }