示例#1
0
 public static bool isPostalCode(Control control)
 {
     if (FormValidators.hasText(control))
     {
         return(Validators.isPostalCode(control.Text));
     }
     return(false);
 }
示例#2
0
 public static bool isMobilePhoneOrNull(Control control)
 {
     if (FormValidators.hasText(control))
     {
         return(Validators.isMobilePhone(control.Text));
     }
     return(true);
 }
示例#3
0
 public static bool isPhoneWithExtensionOrNull(Control control)
 {
     if (FormValidators.hasText(control))
     {
         return(Validators.isPhoneWithExtension(control.Text));
     }
     return(true);
 }
示例#4
0
 public static bool isParticularPhone(Control control)
 {
     if (FormValidators.hasText(control))
     {
         return(Validators.isParticularPhone(control.Text));
     }
     return(false);
 }
示例#5
0
 public static bool isCurrency(Control control)
 {
     if (FormValidators.hasText(control))
     {
         return(Validators.isCurrency(control.Text));
     }
     return(false);
 }
示例#6
0
        /// <summary>
        ///  Return an error message if any control is invalid
        /// </summary>
        /// <param name="validators"></param>
        /// <returns>string</returns>
        public static ControlErrorProvider validForm(ToValidate[] validators)
        {
            string  errorMessage = null;
            Control control      = null;

            foreach (ToValidate validator in validators)
            {
                errorMessage = FormValidators.validControl(validator.Control, validator.ControlValidators, validator.ErrorMessages);
                control      = validator.Control;
                if (!(errorMessage == null))
                {
                    break;
                }
            }
            return(errorMessage == null ? null : new ControlErrorProvider(errorMessage, control));
        }
示例#7
0
        public static bool isEmail(Control control)
        {
            if (FormValidators.hasText(control))
            {
                try
                {
                    MailAddress m = new MailAddress(control.Text);

                    return(true);
                }
                catch (FormatException)
                {
                    return(false);
                }
            }
            return(false);
        }
示例#8
0
        public static List <ControlErrorProvider> validFormTest(ToValidate[] validators)
        {
            List <ControlErrorProvider> errors = new List <ControlErrorProvider>();

            string  errorMessage = null;
            Control control      = null;
            bool    hasErrors    = false;

            foreach (ToValidate validator in validators)
            {
                errorMessage = FormValidators.validControl(validator.Control, validator.ControlValidators, validator.ErrorMessages);
                if (errorMessage != null)
                {
                    hasErrors = true;
                }
                control = validator.Control;
                errors.Add(new ControlErrorProvider(errorMessage, control));
            }
            return(!hasErrors ? null : errors);
        }