Esempio 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);
        }
Esempio 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);
        }
        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);
        }
Esempio 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.ContainsSpecialChars(txtFirstname.Text, out firstnameError) ||
                !error.validFirstName(txtFirstname.Text, out firstnameError))
            {
                correct = false;
                lblFirstnameError.Visible = true;
                lblFirstnameError.Text    = firstnameError;
                txtFirstname.Focus();
            }
            //Check last name:
            string lastnameError = "";

            if (
                //error.ContainsSpecialChars(txtLastname.Text, out lastnameError) ||
                !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 city:
            string cityError = "";

            if (
                //error.ContainsSpecialChars(txtCity.Text, out cityError) ||
                !error.validCity(txtCity.Text, out cityError))
            {
                correct = false;
                lblCityError.Visible = true;
                lblCityError.Text    = cityError;
                txtCity.Focus();
            }
            //Check state:
            string stateError = "";

            if (drpCountries.SelectedValue.Equals("United States"))
            {
                if (!error.validState(drpStates.SelectedIndex, out stateError))
                {
                    correct = false;
                    lblStateError.Visible = true;
                    lblStateError.Text    = stateError;
                    drpStates.Focus();
                }
            }
            else if (!drpCountries.SelectedValue.Equals("United States"))
            {
                if (string.IsNullOrWhiteSpace(txtState.Text))
                {
                    correct = false;
                    lblStateError.Visible = true;
                    lblStateError.Text    = "Invalid input: Please type your state or region.";
                }
            }
            //Check zip:
            string zipError = "";

            if (drpCountries.SelectedValue.Equals("United States"))
            {
                if (error.ContainsSpecialChars(txtZip.Text, out zipError) || !error.validZip(txtZip.Text, out zipError))
                {
                    correct             = false;
                    lblZipError.Visible = true;
                    lblZipError.Text    = zipError;
                    txtZip.Focus();
                }
            }
            else if (!drpCountries.SelectedValue.Equals("United States"))
            {
                if (string.IsNullOrWhiteSpace(txtZip.Text))
                {
                    correct             = false;
                    lblZipError.Visible = true;
                    lblZipError.Text    = "Invalid input: Please type your zip code.";
                }
            }
            //Check address:
            string addressError = "";

            if (
                //error.ContainsSpecialChars(txtAddress.Text, out addressError) ||
                !error.validAddress(txtAddress.Text, out addressError))
            {
                correct = false;
                lblAddressError.Visible = true;
                lblAddressError.Text    = addressError;
                txtAddress.Focus();
            }
            //Check phone:
            string phoneError = "";

            if (drpCountries.SelectedValue.Equals("United States"))
            {
                if (
                    //error.ContainsSpecialChars(txtPhone.Text, out phoneError) ||
                    !error.validPhone(txtPhone.Text, out phoneError))
                {
                    correct = false;
                    lblPhoneError.Visible = true;
                    lblPhoneError.Text    = phoneError;
                    txtPhone.Focus();
                }
            }
            else if (drpCountries.SelectedValue.Equals("United States"))
            {
                if (!error.validInternationalPhone(txtPhone.Text, out phoneError))
                {
                    correct = false;
                    lblPhoneError.Visible = true;
                    lblPhoneError.Text    = phoneError;
                    txtPhone.Focus();
                }
            }
            //Check if no country is selected:
            if (drpCountries.SelectedIndex == 0)
            {
                correct = false;
                lblCountryError.Visible = true;
                lblCountryError.Text    = "Invalid input: Please select a country.";
                drpCountries.Focus();
            }
            //Check selected role:
            string roleError = "";

            if (!error.validRole(drpRole.SelectedIndex, out roleError))
            {
                correct = false;
                lblRoleError.Visible = true;
                lblRoleError.Text    = roleError;
                drpRole.Focus();
            }
            if (txtPatientId.Visible == true)
            {
                string patientId = "";
                if (
                    //error.ContainsSpecialChars(txtLastname.Text, out lastnameError) ||
                    !error.validPatientId(txtPatientId.Text, out patientId))
                {
                    correct = false;
                    lblPatientIdError.Visible = true;
                    lblPatientIdError.Text    = patientId;
                    txtPatientId.Focus();
                }
            }
            else
            {
                lblPatientIdError.Visible = false;
            }
            return(correct);
        }