public static bool ValidateEmail(string email) { if (string.IsNullOrEmpty(email)) { return(false); } //Max length 25 digits if (email.Length > 25) { return(false); } EmailFormatValidator validator = new EmailFormatValidator(); return(validator.IsValid(email, JTokenType.None)); }
public Email() { this.DataType = DataType.Email; this.ControlType = ControlType.TextBox; this.IsConfigurable = true; var requiredValidator1 = new RequiredValidator(); this.AddValidator(requiredValidator1); // var requiredValidator2 = new RangeValidator(); // this.AddValidator(requiredValidator2); var emailformatvalidator = new EmailFormatValidator(); emailformatvalidator.RegexFormat = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" + @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" + @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"; this.AddValidator(emailformatvalidator); var defaultValueValidattor = new DefaultValueValidator(ControlType); this.AddValidator(defaultValueValidattor); }