Exemplo n.º 1
0
        protected bool checkInputs()
        {
            bool        correct = true;
            CheckErrors errors = new CheckErrors();
            string      p1, p2, p3;

            if (!errors.validPassword(txtP1.Text, out p1))
            {
                correct            = false;
                lblP1Error.Visible = true;
                lblP1Error.Text    = p1;
                txtP1.Focus();
            }
            if (!errors.validPassword(txtP2.Text, out p2))
            {
                correct            = false;
                lblP2Error.Visible = true;
                lblP2Error.Text    = p2;
                txtP2.Focus();
            }
            if (!errors.passwordsMatch(txtP1.Text, txtP2.Text, out p3))
            {
                correct          = false;
                lblError.Visible = true;
                lblError.Text    = p3;
                txtP1.Focus();
            }
            return(correct);
        }
Exemplo n.º 2
0
        protected bool checkInputs()
        {
            bool        correct = true;
            CheckErrors errors  = new CheckErrors();
            string      a;

            if (!errors.validQuestion(txtA.Text, out a))
            {
                correct           = false;
                lblAError.Visible = true;
                lblAError.Text    = a;
                txtA.Focus();
            }
            return(correct);
        }
Exemplo n.º 3
0
        protected bool checkInputs()
        {
            bool        correct = true;
            CheckErrors errors = new CheckErrors();
            string      a1, a2, a3;

            if (drpQ1.SelectedIndex == 0)
            {
                correct            = false;
                lblQ1Error.Visible = true;
                lblQ1Error.Text    = "Invalid input: Please select a question";
                drpQ1.Focus();
            }
            if (drpQ2.SelectedIndex == 0)
            {
                correct            = false;
                lblQ2Error.Visible = true;
                lblQ2Error.Text    = "Invalid input: Please select a question";
                drpQ2.Focus();
            }
            if (drpQ3.SelectedIndex == 0)
            {
                correct            = false;
                lblQ3Error.Visible = true;
                lblQ3Error.Text    = "Invalid input: Please select a question";
                drpQ3.Focus();
            }
            if (!errors.validAnswer(txtA1.Text, out a1))
            {
                correct            = false;
                lblA1Error.Visible = true;
                lblA1Error.Text    = a1;
                txtA1.Focus();
            }
            if (!errors.validAnswer(txtA2.Text, out a2))
            {
                correct            = false;
                lblA2Error.Visible = true;
                lblA2Error.Text    = a2;
                txtA2.Focus();
            }
            if (!errors.validAnswer(txtA3.Text, out a3))
            {
                correct            = false;
                lblA3Error.Visible = true;
                lblA3Error.Text    = a3;
                txtA3.Focus();
            }
            //Check specific questions if they are selected:
            if (drpQ1.SelectedValue.Equals("In what year were you born?") || drpQ1.SelectedValue.Equals("Which year did you graduate from high school?") ||
                drpQ1.SelectedValue.Equals("In which year your immediate elder sibling was born?") || drpQ1.SelectedValue.Equals("In which year your immediate younger sibling was born?") ||
                drpQ1.SelectedValue.Equals("What are the last four digits of your current phone number?") || drpQ1.SelectedValue.Equals("When did you graduate from the bachelor school?"))
            {
                if (!txtA1.Text.All(char.IsDigit) || txtA1.Text.Length != 4)
                {
                    correct            = false;
                    lblA1Error.Visible = true;
                    lblA1Error.Text    = "The answer must be a four-digits.";
                    txtA1.Focus();
                }
            }
            if (drpQ2.SelectedValue.Equals("In what year were you born?") || drpQ2.SelectedValue.Equals("Which year did you graduate from high school?") ||
                drpQ2.SelectedValue.Equals("In which year your immediate elder sibling was born?") || drpQ2.SelectedValue.Equals("In which year your immediate younger sibling was born?") ||
                drpQ2.SelectedValue.Equals("What are the last four digits of your current phone number?") || drpQ2.SelectedValue.Equals("When did you graduate from the bachelor school?"))
            {
                if (!txtA2.Text.All(char.IsDigit) || txtA2.Text.Length != 4)
                {
                    correct            = false;
                    lblA2Error.Visible = true;
                    lblA2Error.Text    = "The answer must be a four-digits.";
                    txtA2.Focus();
                }
            }
            if (drpQ3.SelectedValue.Equals("In what year were you born?") || drpQ3.SelectedValue.Equals("Which year did you graduate from high school?") ||
                drpQ3.SelectedValue.Equals("In which year your immediate elder sibling was born?") || drpQ3.SelectedValue.Equals("In which year your immediate younger sibling was born?") ||
                drpQ3.SelectedValue.Equals("What are the last four digits of your current phone number?") || drpQ3.SelectedValue.Equals("When did you graduate from the bachelor school?"))
            {
                if (!txtA3.Text.All(char.IsDigit) || txtA3.Text.Length != 4)
                {
                    correct            = false;
                    lblA3Error.Visible = true;
                    lblA3Error.Text    = "The answer must be a four-digits.";
                    txtA3.Focus();
                }
            }
            if (drpQ1.SelectedValue.Equals("What was your birth month and date?"))
            {
                if (!txtA1.Text.All(char.IsDigit) || txtA1.Text.Length != 4)
                {
                    correct            = false;
                    lblA1Error.Visible = true;
                    lblA1Error.Text    = "The answer must be four-digits, 2-digits month and 2-digits year.";
                    txtA1.Focus();
                }
            }
            if (drpQ2.SelectedValue.Equals("What was your birth month and date?"))
            {
                if (!txtA2.Text.All(char.IsDigit) || txtA2.Text.Length != 4)
                {
                    correct            = false;
                    lblA2Error.Visible = true;
                    lblA2Error.Text    = "The answer must be four-digits, 2-digits month and 2-digits year.";
                    txtA2.Focus();
                }
            }
            if (drpQ3.SelectedValue.Equals("What was your birth month and date?"))
            {
                if (!txtA3.Text.All(char.IsDigit) || txtA3.Text.Length != 4)
                {
                    correct            = false;
                    lblA3Error.Visible = true;
                    lblA3Error.Text    = "The answer must be four-digits, 2-digits month and 2-digits year.";
                    txtA3.Focus();
                }
            }
            return(correct);
        }
Exemplo n.º 4
0
        protected bool checkInput()
        {
            bool correct = true;

            hideAllErrorMessages();
            //First, check if there is any special character within any field:
            CheckErrors error = new CheckErrors();
            //Check first name:
            string firstnameError = "";

            if (!error.validFirstName(txtFirstname.Text, out firstnameError))
            {
                correct = false;
                lblFirstnameError.Visible = true;
                lblFirstnameError.Text    = firstnameError;
                txtFirstname.Focus();
            }
            //Check last name:
            string lastnameError = "";

            if (!error.validLastName(txtLastname.Text, out lastnameError))
            {
                correct = false;
                lblLastnameError.Visible = true;
                lblLastnameError.Text    = lastnameError;
                txtLastname.Focus();
            }
            //Check email:
            string emailError = "";

            if (!error.validEmail(txtEmail.Text, out emailError))
            {
                correct = false;
                lblEmailError.Visible = true;
                lblEmailError.Text    = emailError;
                txtEmail.Focus();
            }

            //Check phone:
            string phoneError = "";

            if (!error.validPhone(txtPhone.Text, out phoneError))
            {
                correct = false;
                lblPhoneError.Visible = true;
                lblPhoneError.Text    = phoneError;
                txtPhone.Focus();
            }

            //Check selected role:
            string roleError = "";

            if (!error.validRole(drpRole.SelectedIndex, out roleError))
            {
                correct = false;
                lblRoleError.Visible = true;
                lblRoleError.Text    = roleError;
                drpRole.Focus();
            }
            return(correct);
        }