How to add Captcha in Custom Sitefinity Form Builder?

Posted by Community Admin on 04-Aug-2018 18:47

How to add Captcha in Custom Sitefinity Form Builder?

All Replies

Posted by Community Admin on 07-Mar-2013 00:00

Hello Team:

I have Custom form builder, i want to include captcha control in the form builder. i found one link from this url "www.sitefinity.com/.../captcha_for_sitefinity_forms" regarding how to add captcha.

i want download that captcha project, but i am not getting where is the link to download captcha form control.

 

Please give the url to download captcha project, so that i will include that project to my custom form builder.

 

Thanks in advance!!!!!!

Saroj Rout

Posted by Community Admin on 12-Mar-2013 00:00

Hello Saroj,

 Thanks for using Sitefinity.

The captcha form project is in the SDK under samples. You can download the SDK from here.

I hope this helps.

Greetings,
Patrick Dunn
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 12-Mar-2013 00:00

Hi

i have downloaded the SDK and installed but didn't get any Captcha project in the sample folder. Please send me the exact link to download or give me a zip file of the captcha project if you have.

 

Thanks in advanced

Posted by Community Admin on 12-Mar-2013 00:00

Dear Patrick

Still think Chaptcha support for forms build should come out of the box.

Saroj vote here: http://www.telerik.com/support/pits.aspx#/details/Issue=10655 already 43 votes. So Telerik this is a requeste feature!

Markus

Posted by Community Admin on 25-Jul-2013 00:00

Does anyone know where the captcha project went? It's no longer in the SDK.

Posted by Community Admin on 31-Jul-2013 00:00

Hello Mark,

The project is not removed from the Sitefinity SDK. Check the Akismet(http://akismet.com/) integration sample available there.

Regards,
Stefani Tacheva
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 Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 31-Jul-2013 00:00

I'm embedding this into my randomsitecontrols on next release...but...

1) Add captcha to your forms toolbox, just edit your toolboxconfig and add this node (on the same level as the others)

<toolbox name="FormControls">
    <sections>
        <add name="Common">
            <tools>
                <add enabled="True" type="Telerik.Web.UI.RadCaptcha, Telerik.Web.UI" title="RadCaptcha" description="RadCaptcha" visibilityMode="None" name="RadCaptcha" />
            </tools>
        </add>
    </sections>
</toolbox>
Now when you edit a form, the captcha will be available for drag\drop and you can edit and set properties on it (like skin\etc).

2) Drop this code into your site...it just inherits from the default form to look for a valid captcha before save...so just enhances the default control, it's not really that "custom"
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Text;
using System.Text.RegularExpressions;
using Telerik.Microsoft.Practices.EnterpriseLibrary.Logging;
using Telerik.Sitefinity.Configuration;
using Telerik.Sitefinity.Modules.Forms;
using Telerik.Sitefinity.Modules.Forms.Web.UI;
using Telerik.Sitefinity.Modules.Forms.Web.UI.Fields;
using Telerik.Sitefinity.Services;
using Telerik.Sitefinity.Web.UI;
using Telerik.Sitefinity.Web.UI.Fields;
using Telerik.Web.UI;
 
namespace RandomSiteControls.Forms
    /// <summary>
    /// Add the captcha control to your toolbox like this
    ///     <toolbox name="FormControls">
    ///         <sections>
    ///             <add name="Common">
    ///                 <tools>
    ///                     <add enabled="True" type="Telerik.Web.UI.RadCaptcha, Telerik.Web.UI" title="RadCaptcha" description="RadCaptcha" visibilityMode="None" name="RadCaptcha" />
    ///                 </tools>
    ///             </add>
    ///         </sections>
    ///     </toolbox>
    /// </summary>
    public class FormCaptcha : FormsControl
    
        protected override void InitializeControls(GenericContainer container)
        
            if (!SystemManager.IsDesignMode)
            
                //Hide the form if JS is disabled, it'll let them bypass the required fields.
                base.InitializeControls(container);
                this.BeforeFormSave += new EventHandler<CancelEventArgs>(FormsControlCustom_BeforeFormSave);
            
        
 
 
        #region EVENTS
        protected void FormsControlCustom_BeforeFormSave(object sender, CancelEventArgs e)
        
            if (this.MyCaptcha != null)
            
                if (!this.MyCaptcha.IsValid)
                
                    e.Cancel = true;
                    this.MyCaptcha.ErrorMessage = this.CaptchaErrorMessage;
                
            
        
 
        #endregion
 
        #region METHODS
 
        #endregion
 
        #region Properties
        private RadCaptcha _captcha = null;
        protected RadCaptcha MyCaptcha
        
            get
            
                if (!SystemManager.IsDesignMode)
                
                    foreach (var control in this.FormControls.Controls[1].Controls)
                    
                        if (control.GetType() == typeof(RadCaptcha))
                        
                            _captcha = control as RadCaptcha;
                            break;
                        
                    
                
 
                return _captcha;
            
        
 
        private string _captchaErrorMessage = "Invalid Code, please try again";
        /// <summary>
        /// This gets edited in advanced mode
        /// </summary>
        public string CaptchaErrorMessage
        
 
            get
            
                return _captchaErrorMessage;
            
            set
            
                _captchaErrorMessage = value;
            
        
        #endregion
    

3) Edit your toolboxes.config again, find the forms control, and set it's type to be the above type
<namespace>.<classname>, <assembly>
Ex: RandomSiteControls.Forms.FormCaptcha, SitefinityWebApp

Done...and works, just implimented this again on another site last night weirdly enough




Posted by Community Admin on 31-Jul-2013 00:00

The Sitefinity Hero strikes again! Thank you Steve

Posted by Community Admin on 31-Jul-2013 00:00

**JUST KEEP IN MIND**
If you have a form on an existing page, you'll need to delete the control, and then re-drag it from the toolbox.  Reason being is the one on the page IS the "FormsControl" not my enhanced "FormCaptcha"

Posted by Community Admin on 31-Jul-2013 00:00

Hello,

Thank you Steve for sharing a solution.

Regards,
Stefani Tacheva
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 Public Issue Tracking system and vote to affect the priority of the items

This thread is closed