public static bool isNumber(Control control) { if (FormValidators.hasText(control)) { return(Validators.isNumber(control.Text)); } return(false); }
/// <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)); }
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); }