protected void validateUser(out bool error)
        {
            error = false;
            String ErrorText = "";
            var    reg       = @"^.*(?=.{6,18})(?=.*\d)(?=.*[a-zA-Z]).*$";
            var    match     = Regex.Match(Password.Text, reg, RegexOptions.IgnoreCase);

            if (EnableRecaptcha)
            {
                RecaptchaControl1.Validate();
                if (!RecaptchaControl1.IsValid)
                {
                    if (!string.IsNullOrEmpty(lblError.Text))
                    {
                        ErrorText += "</br>";
                    }
                    ErrorText       += "The security code you entered is not correct.";
                    error            = true;
                    lblError.Visible = true;
                }
            }


            if (!match.Success)
            {
                if (!string.IsNullOrEmpty(ErrorText))
                {
                    ErrorText += "</br>";
                }
                ErrorText += "Password requirements are not met";
                error      = true;
            }
            if (ddlTitle.SelectedValue == "0")
            {
                if (!string.IsNullOrEmpty(lblError.Text))
                {
                    lblError.Text += "</br>";
                }
                lblError.Text   += "Title is required.";
                error            = true;
                lblError.Visible = true;
            }
            DateTime DOB;

            if (!DateTime.TryParse(txtDOB.Text, out DOB))
            {
                if (!string.IsNullOrEmpty(lblError.Text))
                {
                    lblError.Text += "</br>";
                }
                error            = true;
                lblError.Visible = true;
                lblError.Text   += "Invalid date of birth.";
            }
            if (ddlState.SelectedValue == "0")
            {
                if (!string.IsNullOrEmpty(lblError.Text))
                {
                    lblError.Text += "</br>";
                }
                lblError.Text   += "Address is required.";
                lblError.Visible = true;
                error            = true;
            }
            if (WebSecurity.UserExists(Username.Text))
            {
                if (!string.IsNullOrEmpty(ErrorText))
                {
                    ErrorText += "</br>";
                }
                ErrorText += SystemConstants.ErrorUsernameTaken;
                error      = true;
            }
            if (new CustomerDAC().isEmailAddressExist(Email.Text.ToLower()))
            {
                if (!string.IsNullOrEmpty(lblError.Text))
                {
                    lblError.Text += "</br>";
                }
                lblError.Text   += SystemConstants.ErrorEmailAddressTaken;
                error            = true;
                lblError.Visible = true;
            }

            if (string.IsNullOrEmpty(txtSuburb.Text) || txtSuburb.Text == "suburb" || txtAddress1.Text == "Address Line 1" || ddlState.SelectedValue == "0")
            {
                if (!string.IsNullOrEmpty(ErrorText))
                {
                    ErrorText += "</br>";
                }
                ErrorText += "Address is required";
                error      = true;
            }


            var emailReg   = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
            var emailmatch = Regex.Match(Email.Text, emailReg, RegexOptions.IgnoreCase);

            if (!emailmatch.Success)
            {
                if (!string.IsNullOrEmpty(lblError.Text))
                {
                    lblError.Text += "</br>";
                }
                lblError.Text   += SystemConstants.ErrorInvalidEmail;
                error            = true;
                lblError.Visible = true;
            }
            lblError.Text    = ErrorText;
            divError.Visible = lblError.Visible = error;
        }
示例#2
0
        protected void ValidateUser(out bool error)
        {
            if (EnableRecaptcha)
            {
                RecaptchaControl1.Validate();
                if (!RecaptchaControl1.IsValid)
                {
                    if (!string.IsNullOrEmpty(lblError.Text))
                    {
                        lblError.Text += "</br>";
                    }
                    lblError.Text   += "The security code you entered is not correct.";
                    error            = true;
                    lblError.Visible = true;
                }
            }
            error         = false;
            lblError.Text = "";


            var reg   = @"^.*(?=.{6,18})(?=.*\d)(?=.*[a-zA-Z]).*$";
            var match = Regex.Match(Password.Text, reg, RegexOptions.IgnoreCase);

            if (!match.Success)
            {
                lblError.Text = "Password requirements not met";
                error         = true;
            }

            //if (ddlTitle.SelectedValue == "0")
            //{
            //    if (!string.IsNullOrEmpty(lblError.Text))
            //        lblError.Text += "</br>";
            //    lblError.Text += "Title is required.";
            //    error = true;
            //    lblError.Visible = true;
            //}


            if (ddlState.SelectedValue == "0")
            {
                if (!string.IsNullOrEmpty(lblError.Text))
                {
                    lblError.Text += "</br>";
                }
                lblError.Text   += "address is required.";
                lblError.Visible = true;
                error            = true;
            }
            if (WebSecurity.UserExists(Username.Text))
            {
                if (!string.IsNullOrEmpty(lblError.Text))
                {
                    lblError.Text += "</br>";
                }
                lblError.Text   += SystemConstants.ErrorUsernameTaken;
                error            = true;
                lblError.Visible = true;
            }
            if (new ProviderDAC().ProviderNameExist(txtCompany.Text))
            {
                if (!string.IsNullOrEmpty(lblError.Text))
                {
                    lblError.Text += "</br>";
                }
                lblError.Text   += SystemConstants.ErrorOrganisationNameTaken;
                error            = true;
                lblError.Visible = true;
            }
            if (new ProviderDAC().isEmailAddressExist(Email.Text.ToLower()))
            {
                if (!string.IsNullOrEmpty(lblError.Text))
                {
                    lblError.Text += "</br>";
                }
                lblError.Text   += SystemConstants.ErrorEmailAddressTaken;
                error            = true;
                lblError.Visible = true;
            }
            var emailReg   = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
            var emailmatch = Regex.Match(Email.Text, emailReg, RegexOptions.IgnoreCase);

            if (!emailmatch.Success)
            {
                if (!string.IsNullOrEmpty(lblError.Text))
                {
                    lblError.Text += "</br>";
                }
                lblError.Text   += SystemConstants.ErrorInvalidEmail;
                error            = true;
                lblError.Visible = true;
            }
        }