Try Now
More in this section

Forums / Developing with Sitefinity / Disallow personal emails addresses in forms submissions

Disallow personal emails addresses in forms submissions

2 posts, 0 answered
  1. Wakefly
    Wakefly avatar
    11 posts
    21 Sep 2006
    12 May 2014
    Link to this post

    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.


  2. Junior Dominguez
    Junior Dominguez avatar
    115 posts
    03 Oct 2016
    15 May 2014
    Link to this post
    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);   

    Keep in mind that you need to register the custom control in the Toolbox. If you prefer to replace the default Forms widget go to Administration>>Settings>>Advanced>>Toolboxes>>PageControls>>Sections>>ContentToolboxSection>>Tools>>FormsControl and replace what is in the text box "Control CLR Type or Virtual Path" by the type of the custom control, in this case SitefinityWebApp.MyControls.CustomFormsControl. After that save the changes.
    Otherwise just click in the Create new button in order to create a new widget as shown in this picture and define at least the main fields (Control CLR Type or Virtual Path ,  Name and Title) as shown here.

    Kind Regards,
    Junior Dominguez
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
2 posts, 0 answered