private bool IsFormValid()
        {
            if (OldPasswordTextBox.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Old password is Required.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                OldPasswordTextBox.Focus();
                return(false);
            }

            if (NewPasswordTextBox.Text.Trim() == string.Empty)
            {
                MessageBox.Show("New password is Required.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                NewPasswordTextBox.Focus();
                return(false);
            }

            if (ConfirmPasswordTextBox.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Confirm password is Required.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ConfirmPasswordTextBox.Focus();
                return(false);
            }

            if (NewPasswordTextBox.Text.Trim() != ConfirmPasswordTextBox.Text.Trim())
            {
                MessageBox.Show("New and Confirm password does not match.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ConfirmPasswordTextBox.Focus();
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
 protected override void OnShown(EventArgs e)
 {
     if (OldPasswordTextBox.CanSelect)
     {
         OldPasswordTextBox.Focus();
     }
     base.OnShown(e);
 }
        private void ResetFormControl()
        {
            NewPasswordTextBox.Clear();
            OldPasswordTextBox.Clear();
            ConfirmPasswordTextBox.Clear();

            OldPasswordTextBox.Focus();
        }