Exemplo n.º 1
0
        /// <summary>
        /// make sure that full name is entered
        /// </summary>
        /// <returns>true if the name is filled in, flase otherwise</returns>
        private bool ReadAndValidateName()
        {
            string fName = txtFirstName.Text;
            string lName = txtSurname.Text;

            if (InputUtility.IsInValidString(fName))
            {
                MessageBox.Show("Invalid input in the first name field!\nPlease enter a valid name (at least one character is required)", "Invalid Input!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //put focus on requred field
                txtFirstName.Focus();
                txtFirstName.Text = " ";
                txtFirstName.SelectAll();
            }
            else if (InputUtility.IsInValidString(lName))
            {
                MessageBox.Show("Invalid input in the last name field!\nPlease enter a valid name (at least one character is required)", "Invalid Input!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //put focus on requred field
                txtSurname.Focus();
                txtSurname.Text = " ";
                txtSurname.SelectAll();
            }
            else
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// ensure that a proper email address is entered
        /// </summary>
        /// <returns></returns>
        private bool ReadAndValidateEmail()
        {
            string email = txtEmail.Text;

            if (!InputUtility.IsValidEmail(email))
            {
                MessageBox.Show("Invalid email address!", "Invalid Input!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtEmail.Focus();
                txtEmail.Text = " ";
                txtEmail.SelectAll();
            }
            else
            {
                return(true);
            }

            return(false);
        }