Пример #1
0
		private bool ValidateMacroForm()
		{
			ValidationMethods validationMethods = new ValidationMethods();

			List<FormField> formFields = new List<FormField> { };
			FormField.ValidationHandler[] stringValidationHandlers = new FormField.ValidationHandler[] { validationMethods.StringIsNotEmpty };
			FormField.ValidationHandler[] nameValidationHandlers = new FormField.ValidationHandler[] { validationMethods.StringIsNotEmpty, validationMethods.StringHasNoSpecialChars };

			formFields.Add(new FormField(macroNameInput, macroNameError, stringValidationHandlers));
			formFields.Add(new FormField(macroCommandInput, macroCommandError, stringValidationHandlers));

			bool formIsValid = true;
			foreach (FormField formField in formFields)
			{
				formField.FieldErrorMessageWidget.Visible = false;
				bool fieldIsValid = formField.Validate();
				if (!fieldIsValid)
				{
					formIsValid = false;
				}
			}
			return formIsValid;
		}
Пример #2
0
        private bool ValidateContactForm()
        {
            ValidationMethods validationMethods = new ValidationMethods();
            
            List<FormField> formFields = new List<FormField>{};
            FormField.ValidationHandler[] stringValidationHandlers = new FormField.ValidationHandler[] { validationMethods.StringIsNotEmpty };
            FormField.ValidationHandler[] emailValidationHandlers = new FormField.ValidationHandler[] { validationMethods.StringIsNotEmpty, validationMethods.StringLooksLikeEmail };

            formFields.Add(new FormField(questionInput, questionErrorMessage, stringValidationHandlers));
            formFields.Add(new FormField(detailInput, detailErrorMessage, stringValidationHandlers));
            formFields.Add(new FormField(emailInput, emailErrorMessage, emailValidationHandlers));
            formFields.Add(new FormField(nameInput, nameErrorMessage, stringValidationHandlers));

            bool formIsValid = true;
            foreach (FormField formField in formFields)
            {
                formField.FieldErrorMessageWidget.Visible = false;
                bool fieldIsValid = formField.Validate();
                if (!fieldIsValid)
                {
                    formIsValid = false;
                }
            }
            return formIsValid;
        }
        private bool ValidateContactForm()
        {
            ValidationMethods validationMethods = new ValidationMethods();
            
            List<FormField> formFields = new List<FormField>{};
            FormField.ValidationHandler[] stringValidationHandlers = new FormField.ValidationHandler[] { validationMethods.StringIsNotEmpty };
            FormField.ValidationHandler[] emailValidationHandlers = new FormField.ValidationHandler[] { validationMethods.StringIsNotEmpty, validationMethods.StringLooksLikeEmail };
            FormField.ValidationHandler[] phoneValidationHandlers = new FormField.ValidationHandler[] { validationMethods.StringIsNotEmpty, validationMethods.StringLooksLikePhoneNumber };

            formFields.Add(new FormField(phoneNumberInput, phoneNumberErrorMessage, phoneValidationHandlers));
            formFields.Add(new FormField(emailAddressInput, emailAddressErrorMessage, emailValidationHandlers));

            bool formIsValid = true;
            foreach (FormField formField in formFields)
            {
                //Only validate field if visible
                if (formField.FieldEditWidget.Parent.Visible == true)
                {
                    formField.FieldErrorMessageWidget.Visible = false;
                    bool fieldIsValid = formField.Validate();
                    if (!fieldIsValid)
                    {
                        formIsValid = false;
                    }
                }
            }
            return formIsValid;
        }