Disallow personal emails addresses in forms submissions

Posted by Community Admin on 04-Aug-2018 15:09

Disallow personal emails addresses in forms submissions

All Replies

Posted by Community Admin on 12-May-2014 00:00

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.

 

Posted by Community Admin on 15-May-2014 00:00

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
Telerik
 
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
 

This thread is closed