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); }