Disallow personal emails addresses in forms submissions
How might I be able to handle email address submissions from users who attempt to user their personal email addresses (i.e. - gmail, yahoo, hotmail, etc.)?
We want to disallow submissions from personal email addresses and only allow company email addresses.
Hi Dean,
An approach may consist on extending the default FormsControl and overriding the Submit_Click method. In there you can place the logic. For instance, it may look like:
public class CustomFormsControl : FormsControl protected override void Submit_Click(object sender, EventArgs e) var emailField = this.FieldControls.Where(c => c.MetaField.FieldName == "txtEmail").SingleOrDefault(); if (emailField != null) Regex re = new Regex(@"^[a-zA-Z]+@yourdomain\.com$"); // simple regular expression to check email. if (re.IsMatch((emailField as FormTextBox).DefaultStringValue)) base.Submit_Click(sender, e);