private bool CheckFields() { if (Sex.SelectedItemId == 0) { checkFormMessage = Resource.String.SexEmpty; Sex.RequestFocus(); return(false); } if (Email.Text.Trim() == "") { checkFormMessage = Resource.String.EmailEmpty; Email.RequestFocus(); return(false); } int lastDotPos = Email.Text.LastIndexOf("."); if (lastDotPos < Email.Text.Length - 5) { checkFormMessage = Resource.String.EmailWrong; return(false); } //If the extension is long, the regex will freeze the app. Regex regex = new Regex(Constants.EmailFormat); if (!regex.IsMatch(Email.Text)) { checkFormMessage = Resource.String.EmailWrong; Email.RequestFocus(); return(false); } if (Password.Text.Trim().Length < 6) { checkFormMessage = Resource.String.PasswordShort; Password.RequestFocus(); return(false); } if (Password.Text.Trim() != ConfirmPassword.Text.Trim()) { checkFormMessage = Resource.String.ConfirmPasswordNoMatch; ConfirmPassword.RequestFocus(); return(false); } if (Username.Text.Trim() == "") { checkFormMessage = Resource.String.UsernameEmpty; Username.RequestFocus(); return(false); } if (Username.Text.Trim().Substring(Username.Text.Trim().Length - 1) == "\\") { checkFormMessage = Resource.String.UsernameBackslash; Username.RequestFocus(); return(false); } if (Name.Text.Trim() == "") { checkFormMessage = Resource.String.NameEmpty; Name.RequestFocus(); return(false); } if (Name.Text.Trim().Substring(Name.Text.Trim().Length - 1) == "\\") { checkFormMessage = Resource.String.NameBackslash; Name.RequestFocus(); return(false); } if (uploadedImages.Count == 0) { checkFormMessage = Resource.String.ImagesEmpty; Images.RequestFocus(); return(false); } if (Description.Text.Trim() == "") { checkFormMessage = Resource.String.DescriptionEmpty; Description.RequestFocus(); return(false); } if (Description.Text.Substring(Description.Text.Length - 1) == "\\") { checkFormMessage = Resource.String.DescriptionBackslash; Description.RequestFocus(); return(false); } return(true); }