Example #1
0
        private bool CheckFields()
        {
            if (DescriptionText.Text.Trim() == "")
            {
                checkFormMessage = LangEnglish.DescriptionEmpty;
                DescriptionText.BecomeFirstResponder();
                return(false);
            }
            if (DescriptionText.Text.Substring(DescriptionText.Text.Length - 1) == "\\")
            {
                checkFormMessage = LangEnglish.DescriptionBackslash;
                DescriptionText.BecomeFirstResponder();
                return(false);
            }

            if (AccountDataSection.Frame.Height != 0)
            {
                if (Email.Text.Trim() == "")
                {
                    checkFormMessage = LangEnglish.EmailEmpty;
                    Email.BecomeFirstResponder();
                    return(false);
                }
                //If the extension is long, the regex will freeze the app.
                int lastDotPos = Email.Text.LastIndexOf(".");
                if (lastDotPos < Email.Text.Length - 5)
                {
                    checkFormMessage = LangEnglish.EmailWrong;
                    return(false);
                }
                Regex regex = new Regex(Constants.EmailFormat); //when the email extension is long, it will take ages for the regex to finish
                if (!regex.IsMatch(Email.Text))
                {
                    checkFormMessage = LangEnglish.EmailWrong;
                    Email.BecomeFirstResponder();
                    return(false);
                }
                if (Username.Text.Trim() == "")
                {
                    checkFormMessage = LangEnglish.UsernameEmpty;
                    Username.BecomeFirstResponder();
                    return(false);
                }
                if (Username.Text.Trim().Substring(Username.Text.Trim().Length - 1) == "\\")
                {
                    checkFormMessage = LangEnglish.UsernameBackslash;
                    Username.BecomeFirstResponder();
                    return(false);
                }
                if (Name.Text.Trim() == "")
                {
                    checkFormMessage = LangEnglish.NameEmpty;
                    Name.BecomeFirstResponder();
                    return(false);
                }
                if (Name.Text.Trim().Substring(Name.Text.Trim().Length - 1) == "\\")
                {
                    checkFormMessage = LangEnglish.NameBackslash;
                    Name.BecomeFirstResponder();
                    return(false);
                }
            }

            if (ChangePasswordSection.Frame.Height != 0)
            {
                if (OldPassword.Text.Trim().Length < 6)
                {
                    checkFormMessage = LangEnglish.PasswordShort;
                    OldPassword.BecomeFirstResponder();
                    return(false);
                }
                if (NewPassword.Text.Trim().Length < 6)
                {
                    checkFormMessage = LangEnglish.PasswordShort;
                    NewPassword.BecomeFirstResponder();
                    return(false);
                }
                if (OldPassword.Text.Trim() == NewPassword.Text.Trim())
                {
                    checkFormMessage = LangEnglish.PasswordNotChanged;
                    NewPassword.BecomeFirstResponder();
                    return(false);
                }
                if (NewPassword.Text.Trim() != ConfirmPassword.Text.Trim())
                {
                    checkFormMessage = LangEnglish.ConfirmPasswordNoMatch;
                    ConfirmPassword.BecomeFirstResponder();
                    return(false);
                }
            }
            return(true);
        }