Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Google reCAPTCHA in a BizForm : tutorial View modes: 
User avatar
Member
Member
efusien - 11/10/2010 1:41:04 PM
   
Google reCAPTCHA in a BizForm : tutorial
Hello,

Here is a tutorial to install the Captcha from Google (reCAPTCHA) in a BizForm for Kentico.

Sources :
- From Kentico Developer's guide.
- From reCAPTCHA developer's guide.

Tutorial :

1. Log in or sign in a Google account and get a public and private key for the reCAPTCHA webservice.

2. Open the web project in Visual Studio (or Visual Web Developer) using the WebProject.sln file or using File -> Open -> website in Visual Studio.

3. Right-click the CMSFormControls folder and choose Add New Item.
Choose to create a new Web User Control and call it recaptcha.ascx.

4. Add the following code in the recaptcha.ascx file :
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="recaptcha.ascx.cs" Inherits="CMSFormControls_recaptcha" %>
<%@ Register TagPrefix="recaptcha" Namespace="Recaptcha" Assembly="Recaptcha" %>
<recaptcha:RecaptchaControl
ID="recaptcha"
runat="server"
PublicKey="enter your public key here"
PrivateKey="enter your private key here"
Theme="red"
/>

You can find all options on the reCAPTCHA developer's guide.

5. Switch to the code behind. Add the following code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class CMSFormControls_recaptcha : CMS.FormControls.FormEngineUserControl{
protected void Page_Load(object sender, EventArgs e){
}
public override bool IsValid(){
Page.Validate();
if (Page.IsValid){
return true;
}
else{
return false;
}
}
}

6. Login to Kentico backoffice. Go to Site Manager -> Development -> Form controls and click New form control. Enter the following values:
- Control display name: Recaptcha
- Control code name: RecaptchaControl
- Control file name: ~/CMSFormControls/recaptcha.ascx
Check the boxes :
- Use control for text
- Show control in document types
- Show control in BizForms
and click OK.

7. Go to CMS Desk -> Tools -> BizForms:
Edit your form. Go to Fields tab and add a new tab:
- Column name: SecurityCode
- Show on public form: check
- Field caption: Security Code
- Field type: select "Recaptcha"
- Maximum length: 100
- Allow empty value: check
- Default value: (empty)
and click OK.


Tips:
As the Customizing the Look and Feel of reCAPTCHA page explains, you can customize the captcha.
I try to use the "custom" theme. But it seems to works only if you add Javascript to your CMSformControl.
See below:
<recaptcha:RecaptchaControl
ID="recaptcha"
runat="server"
PublicKey="enter your public key here"
PrivateKey="enter your private key here"
Theme="custom"
/>
<script type="text/javascript">
var RecaptchaOptions = {
theme : 'custom',
custom_theme_widget : 'recaptcha_widget',
lang: '<%=CMSContext.CurrentDocument.DocumentCulture.Substring(0,2)%>'
};
</script>

<div id="recaptcha_widget" style="display:none">
Here you have to put all the captcha tags, as explain in the Customizing the Look and Feel of reCAPTCHA page.
</div>

Please note here the <%=CMSContext.CurrentDocument.DocumentCulture.Substring(0,2)%> get the current language (like "fr" or "en"). It can be usefull for multiple language web sites.

User avatar
Member
Member
ian dunn - 12/21/2010 11:27:46 AM
   
RE:Google reCAPTCHA in a BizForm : tutorial
There's one extra step you have to take. You have to download the reCAPTCHA library from http://code.google.com/p/recaptcha/downloads/list?q=label:aspnetlib-Latest and reference it in the project. If you don't do that you'll get an error saying that it can't find the assembly.

From the reCAPTCHA docs:
Add a reference on your website to library/bin/Release/Recaptcha.dll: On the Visual Studio Website menu, choose Add Reference and then click the .NET tab in the dialog box. Select the Recaptcha.dll component from the list of .NET components and then click OK. If you don't see the component, click the Browse tab and look for the assembly file on your hard drive.

If you're not using Visual Studio you can just drop the files in the /Bin directory on the FTP site.

User avatar
Member
Member
Raymond A - 2/28/2011 5:58:24 AM
   
RE:Google reCAPTCHA in a BizForm : tutorial
Hi, thanks for the reCaptcha tutorials .
But i do have an issue, even thought i submitted the correct word it still display the error message in the bizform.
Is there something else required? i have used a global key for localhost since im not yet in to production.

Thanks

User avatar
Member
Member
Raymond A - 2/28/2011 6:02:10 AM
   
RE:Google reCAPTCHA in a BizForm : tutorial
Sorry , got it working;I didn't make the field accept empty values as suggested.
Thanks

User avatar
Member
Member
Gavin_Paolucci-Kleinow-URMC.Rochester - 1/4/2013 11:05:53 AM
   
RE:Google reCAPTCHA in a BizForm : tutorial
We were having a lot of trouble with this example source for the code behind (the control was working on some servers but not others), and found a solution. The code given validates the entire page, instead of just the recaptcha control.

The following code behind source validates only the recaptcha control, and is a bit more clean. It is working for us consistently.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class CMSFormControls_Captcha_reCaptcha : CMS.FormControls.FormEngineUserControl
{
public override bool IsValid()
{
recaptcha.Validate();
return recaptcha.IsValid;
}
}

User avatar
Member
Member
rob.nisbet-sanlam - 1/11/2013 3:01:58 AM
   
RE:Google reCAPTCHA in a BizForm : tutorial
Hi, anyone had any problems with reCaptcha and v7 ?

My actual implementation is that I've got my recpatcha control in a webpart, so it's exactly the same as above but it's codebehind Inherits CMSAbstractWebPart rather than FormEngineUserControl. I use the ServerValidateEvent to validate the captcha.

All this worked fine in v4, but I've upgraded to v7 and the entire recaptcha doesnt even show any more. Wondering if anyone else has had this problem, the recpatcha code hasnt changed and is simple so I can only assume somethign fundamental has changed in Kentico to stop it working, but I have no idea how to debug this.

Any help very much appreciated as this is now a live system error and I've had to disable the recpatcha.
Many thanks
Rob

as an aside, trying the above code in v7 gives the following error:
Error 24 'CMSFormControls_recaptcha' does not implement inherited abstract member 'CMS.FormControls.FormEngineUserControl.Value.get'.

User avatar
Member
Member
Gavin_Paolucci-Kleinow-URMC - 1/11/2013 8:11:59 AM
   
RE:Google reCAPTCHA in a BizForm : tutorial
Rob,
Could you show your .ascx and .cs so we can help troublehsoot?

User avatar
Member
Member
rob.nisbet-sanlam - 1/11/2013 8:49:21 AM
   
RE:Google reCAPTCHA in a BizForm : tutorial
Hi Gavin, thanks for taking a look at it.
The webpart itself is a customised membership creasteuserwizard with a lot of junk to be ignored. If I take the recaptcha code out into a .aspx file it works fine, seems something odd happening in v7 when it's in a webpart which worked before the upgrade. Looking at the source when generated via webpart some of the <script> tags acessing the code from google.com don't appear.
Thanks .....

Rob
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="MemSvcsRegister.ascx.vb"
Inherits="CMSWebParts_Membership_MemSvcsRegister" %>

<%@ Register Assembly="skmValidators" Namespace="skmValidators" TagPrefix="cc1" %>
<%@ Register Assembly="AjaxControlToolkit" TagPrefix="ajaxcontrol" Namespace="AjaxControlToolkit" %>
<%@ Register TagPrefix="recaptcha" Namespace="Recaptcha" Assembly="Recaptcha" %>

<asp:CreateUserWizard ID="CreateUserWizard1" runat="server" MembershipProvider="CustomizedProvider"
CssClass="register" LoginCreatedUser="true" CreateUserButtonText="Submit">
<WizardSteps>
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
<ContentTemplate>
<div id="genericform">
<table cellspacing="0" cellpadding="0">
<tr>
<th colspan="3" align="center">
<p >To register please complete your details below and press the submit button at the bottom of the page. If you have any questions then please call us on 0117 926 6366 and ask to speak to our customer services team for assistance.</p>
</th>
</tr>
<tr>
<td colspan="3" style="color:Red; background-color:inherit; border-width:0">
<asp:ValidationSummary ID="ValidationSummary1" DisplayMode="BulletList" ShowMessageBox="False"
EnableClientScript="true" runat="server" Font-Bold="true" ValidationGroup="CreateUserWizard1"/>
<asp:Label ID="lblCaptchaSummaryError" Font-Bold="true" runat="server" ></asp:Label><br />
<asp:Label ID="ErrorMessage" runat="server" Font-Bold="true" EnableViewState="False" />

</td>
</tr>
<tr>
<th colspan="3">
<h2>USER NAME</h2>
</th>
</tr>
<tr>
<th colspan="3">
<p>Note: the user name should have no breaks between words, and the password must be 7-16 characters in length and contain three of the following : upper case letter; lower case letter; a special character; a number.</p>
</th>
</tr>
<tr>
<th>
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label></th>
<td>
<span class="required">*</span></td>
<td>
<asp:TextBox ID="UserName" runat="server" AutoCompleteType="Disabled"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="UserNameRegex" runat="server" ControlToValidate="UserName"
ValidationExpression="(^[a-zA-Z][\w\.]{5,19})$" ValidationGroup="CreateUserWizard1" Display="Dynamic"
ErrorMessage="Username must start with a letter, be 6-20 characters in length and must only contain letters or numbers">*</asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<th>
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label></th>
<td>
<span class="required">*</span></td>
<td>
<asp:TextBox ID="Password" runat="server" TextMode="Password" AutoCompleteType="Disabled"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>

<!-- password strength control -->
<ajaxcontrol:PasswordStrength ID="passwordStrength" runat="server"
TargetControlID="Password"
DisplayPosition="AboveRight"
StrengthIndicatorType="Text"
PreferredPasswordLength="7"
PrefixText="Strength:"
MinimumNumericCharacters="1"
MinimumSymbolCharacters="1"
RequiresUpperAndLowerCaseCharacters="true"
TextStrengthDescriptions="Very Poor;Weak;Average;Strong;Excellent"
TextStrengthDescriptionStyles="passwordStrengthTextPoor;passwordStrengthTextWeak;passwordStrengthTextAverage;passwordStrengthTextStrong;passwordStrengthTextExcellent"
CalculationWeightings="50;15;15;20" />

</td>
</tr>
<tr>
<th>
<asp:Label ID="ConfirmPasswordLabel" runat="server" AssociatedControlID="ConfirmPassword">Confirm Password:</asp:Label></th>
<td>
<span class="required">*</span></td>
<td>
<asp:TextBox ID="ConfirmPassword" runat="server" TextMode="Password" AutoCompleteType="Disabled"></asp:TextBox>
<asp:RequiredFieldValidator ID="ConfirmPasswordRequired" runat="server" ControlToValidate="ConfirmPassword"
ErrorMessage="Confirm Password is required." ToolTip="Confirm Password is required."
ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<th>
<asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email">E-mail:</asp:Label></th>
<td>
<span class="required">*</span></td>
<td>
<asp:TextBox ID="Email" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="EmailRegex" runat="server"
ControlToValidate="Email" ErrorMessage="A valid Email address is required" Display="Dynamic"
ValidationGroup="CreateUserWizard1" ValidationExpression="^.+@[^\.].*\.[a-z]{2,}$">*</asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="EmailRequired" runat="server" ControlToValidate="Email"
ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<th>
<asp:Label ID="QuestionLabel" runat="server" AssociatedControlID="Question">Security Question:</asp:Label></th>
<td>
<span class="required">*</span></td>
<td>
<asp:DropDownList ID="Question" runat="server">
<asp:ListItem Value="">Please select one</asp:ListItem>
<asp:ListItem>Mother's birthplace</asp:ListItem>
<asp:ListItem>Name of first school</asp:ListItem>
<asp:ListItem>Best childhood friend</asp:ListItem>
<asp:ListItem>Name of first pet</asp:ListItem>
<asp:ListItem>Favorite teacher</asp:ListItem>
<asp:ListItem>Mother's maiden name</asp:ListItem>
<asp:ListItem>Registration number of favourite car</asp:ListItem>
<asp:ListItem>Favorite historical person</asp:ListItem>
<asp:ListItem>Make/Model of first car</asp:ListItem>
<asp:ListItem>Grandfather's occupation</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="QuestionRequired" runat="server" ControlToValidate="Question"
ErrorMessage="Security question is required." ToolTip="Security question is required."
ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<th>
<asp:Label ID="AnswerLabel" runat="server" AssociatedControlID="Answer">Security Answer:</asp:Label></th>
<td>
<span class="required">*</span></td>
<td>
<asp:TextBox ID="Answer" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="AnswerRequired" runat="server" ControlToValidate="Answer"
ErrorMessage="Security answer is required." ToolTip="Security answer is required."
ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<th colspan="3">

<!-- password versus username validator - executed client side -->
<asp:CustomValidator runat="server" id="CustomValidator1" ControlToValidate="Password"
ClientValidationFunction="cusvalPasswordUsername" Display="Dynamic" Font-Bold="false"
ErrorMessage="The password cannot contain your username, please try again." ValidationGroup="CreateUserWizard1" />

<script type="text/javascript" language="javascript">
function cusvalPasswordUsername(sender, args)
{
var password = args.Value;
var username = document.getElementById('<%= CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName").ClientID %>').value

if (password.toUpperCase().indexOf(username.toUpperCase()) == -1)
{
args.IsValid = true;
return;
}
args.IsValid = false;
}
</script>

<asp:RegularExpressionValidator ID="RegularExpressionValidator2" Font-Bold="false" runat="server"
ValidationExpression="(?=^[^\s]{7,16}$)((?=.*?\d)(?=.*?[A-Z])(?=.*?[a-z])|(?=.*?\d)(?=.*?[^\w\d\s])(?=.*?[a-z])|(?=.*?[^\w\d\s])(?=.*?[A-Z])(?=.*?[a-z])|(?=.*?\d)(?=.*?[A-Z])(?=.*?[^\w\d\s]))^.*"
ErrorMessage="Password must be 7-16 characters in length and contain three of the following : upper case letter; lower case letter; a special character; a number."
ToolTip="Password must be 7-16 characters in length and contain three of the following : upper case letter; lower case letter; a special character; a number."
ControlToValidate="Password"
ValidationGroup="CreateUserWizard1" Display="Dynamic"></asp:RegularExpressionValidator>
<asp:CompareValidator ID="PasswordCompare" Font-Bold="false" runat="server" ControlToCompare="Password"
ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match.<br />"
ValidationGroup="CreateUserWizard1"></asp:CompareValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" Font-Bold="false" runat="server" ErrorMessage="Username must start with a letter, be at least 6 characters in length and must only contain letters or numbers<br />"
ValidationExpression="(^[a-zA-Z][\w\.]{5,19})$" ControlToValidate="UserName"
ValidationGroup="CreateUserWizard1" Display="Dynamic"></asp:RegularExpressionValidator>
<asp:RegularExpressionValidator ID="EmailRegex2" Font-Bold="false" runat="server"
ControlToValidate="Email" ErrorMessage="A valid Email address is required" Display="Dynamic"
ValidationGroup="CreateUserWizard1" ValidationExpression="^.+@[^\.].*\.[a-z]{2,}$"></asp:RegularExpressionValidator>
</th>
</tr>
<tr>
<th colspan="3" class="head">
<h2>
PERSONAL DETAILS</h2>
</th>
</tr>
<tr>
<th>
<asp:Label ID="lblTitle" runat="server" AssociatedControlID="drpTitle">Title:</asp:Label></th>
<td>
<span class="required">*</span></td>
<td>
<asp:DropDownList ID="drpTitle" runat="server">
<asp:ListItem Value="">Please select one</asp:ListItem>
<asp:ListItem>Mr</asp:ListItem>
<asp:ListItem>Mrs</asp:ListItem>
<asp:ListItem>Miss</asp:ListItem>
<asp:ListItem>Ms</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rqdTitle" runat="server" ControlToValidate="drpTitle"
ErrorMessage="Title is required." ToolTip="Title is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<th>
<asp:Label ID="lblFirstName" runat="server" AssociatedControlID="txtFirstName">First Names:</asp:Label></th>
<td>
<span class="required">*</span></td>
<td>
<asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rqdFirstName" Display="Dynamic" runat="server" ControlToValidate="txtFirstName"
ErrorMessage="First names are required." ToolTip="First names are required."
ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<th>
<asp:Label ID="lblLastName" runat="server" AssociatedControlID="txtLastName">Surname:</asp:Label></th>
<td>
<span class="required">*</span></td>
<td>
<asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rqdLastName" runat="server" ControlToValidate="txtLastName"
ErrorMessage="Last name is required." ToolTip="Last name is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<th>
<asp:Label ID="lblFSAIndRegNo" runat="server" AssociatedControlID="txtFSAIndRegNo">FSA Individual Reg No:</asp:Label></th>
<td>
 </td>
<td>
<asp:TextBox ID="txtFSAIndRegNo" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtLastName"
ErrorMessage="Last name is required." ToolTip="Last name is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<th>
</th>
<td>
 </td>
<td>
<a href="http://www.fsa.gov.uk/" target="_blank">Locate FSA registration(s) number</a></td>
</tr>
<tr>
<th colspan="3" class="head">
<h2>
YOUR COMPANY</h2>
</th>
</tr>
<tr>
<th>
<asp:Label ID="lblOrganisationName" runat="server" AssociatedControlID="txtOrganisationName">Name:</asp:Label></th>
<td>
<span class="required">*</span></td>
<td>
<asp:TextBox ID="txtOrganisationName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rqdOrganisationName" runat="server" ControlToValidate="txtOrganisationName"
ErrorMessage="Company name is required." ToolTip="Company name is required."
ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<th>
<asp:Label ID="lblFSARegNo" runat="server" AssociatedControlID="txtFSARegNo">FSA Registration No:</asp:Label></th>
<td>
 </td>
<td>
<asp:TextBox ID="txtFSARegNo" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="FSARegNoValid" runat="server" ErrorMessage="Invalid FSA Registration number"
ValidationExpression="^[1-9][0-9][0-9][0-9][0-9][0-9]$" ControlToValidate="txtFSARegNo"
ValidationGroup="CreateUserWizard1">*</asp:RegularExpressionValidator></td>
</tr>
<tr>
<th>
<asp:Label ID="lblAddress1" runat="server" AssociatedControlID="txtAddress1">Address:</asp:Label></th>
<td>
<span class="required">*</span></td>
<td>
<asp:TextBox ID="txtAddress1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rqdAddress1" runat="server" ControlToValidate="txtAddress1"
ErrorMessage="Address is required." ToolTip="Last name is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<th>
</th>
<td>
 </td>
<td>
<asp:TextBox ID="txtAddress2" runat="server"></asp:TextBox></td>
</tr>
<tr>
<th>
</th>
<td>
 </td>
<td>
<asp:TextBox ID="txtAddress3" runat="server"></asp:TextBox></td>
</tr>
<tr>
<th>
</th>
<td>
 </td>
<td>
<asp:TextBox ID="txtAddress4" runat="server"></asp:TextBox></td>
</tr>
<tr>
<th>
<asp:Label ID="lblPostcode" runat="server" AssociatedControlID="txtPostcode">Postcode:</asp:Label></th>
<td>
<span class="required">*</span></td>
<td>
<asp:TextBox ID="txtPostcode" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rqdPostcode" runat="server" ControlToValidate="txtPostcode"
ErrorMessage="Postcode is required." ToolTip="Postcode is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<th>
<asp:Label ID="lblCountry" runat="server" AssociatedControlID="drpCountry">Country:</asp:Label></th>
<td>
<span class="required">*</span></td>
<td>
<asp:DropDownList ID="drpCountry" runat="server">
<asp:ListItem Value="">Please select one</asp:ListItem>
<asp:ListItem>Zimbabwe</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rqdCountry" runat="server" ControlToValidate="drpCountry"
ErrorMessage="Country is required." ToolTip="Country is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<th>
<asp:Label ID="lblRole" runat="server" AssociatedControlID="drpRole">Role:</asp:Label></th>
<td>
<span class="required">*</span></td>
<td>
<asp:DropDownList ID="drpRole" runat="server">
<asp:ListItem Value="">Please select one</asp:ListItem>
<asp:ListItem>Administration</asp:ListItem>
<asp:ListItem>Compliance</asp:ListItem>
<asp:ListItem>Director</asp:ListItem>
<asp:ListItem>Finance</asp:ListItem>
<asp:ListItem>Sales</asp:ListItem>
<asp:ListItem>Other</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="drpRole"
ErrorMessage="Role is required." ToolTip="Role is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<th>
<asp:Label ID="lblJobTitle" runat="server" AssociatedControlID="txtJobTitle">Job Title:</asp:Label></th>
<td>
<span class="required">*</span></td>
<td>
<asp:TextBox ID="txtJobTitle" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rqdJobTitle" runat="server" ControlToValidate="txtJobTitle"
ErrorMessage="Job Title is required." ToolTip="Job Title is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<th colspan="3" class="head">
<h2>
CONTACT</h2>
</th>
</tr>
<tr>
<th>
<asp:Label ID="lblPhone" runat="server" AssociatedControlID="txtPhone">Phone:</asp:Label></th>
<td>
<span class="required">*</span></td>
<td>
<asp:TextBox ID="txtPhone" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rqdPhone" runat="server" ControlToValidate="txtPhone"
ErrorMessage="Phone number is required." ToolTip="Phone number is required."
ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<th>
<asp:Label ID="lblMobile" runat="server" AssociatedControlID="txtMobile">Mobile:</asp:Label></th>
<td>
 </td>
<td>
<asp:TextBox ID="txtMobile" runat="server"></asp:TextBox></td>
</tr>
<tr>
<th>
<asp:Label ID="lblFax" runat="server" AssociatedControlID="txtFax">Fax:</asp:Label></th>
<td>
 </td>
<td>
<asp:TextBox ID="txtFax" runat="server"></asp:TextBox></td>
</tr>
<tr>
<th colspan="3" class="head">
<h2>
TERMS & CONDITIONS</h2>
</th>
</tr>
<tr>
<td>
 </td>
<td>
 </td>
<td>
<asp:CheckBox ID="chkTerms" runat="server" Text="  I have read and accept the <a href='Terms-and-Conditions.aspx' target='_blank'>terms and conditions</a><br /><em>      This will open in a new window</em>" />
<cc1:CheckBoxValidator ID="CheckBoxValidator1" runat="server" ControlToValidate="chkTerms"
MustBeChecked="true" ErrorMessage="Please confirm you have read and<br/>accepted the terms and conditions"
ValidationGroup="CreateUserWizard1" Font-Bold="true" Display="Dynamic">*</cc1:CheckBoxValidator></td>
</tr>

<!--tr>
<td colspan="3">
We would like to send you details of our products and services by e-mail from time to time in the future. You can accept this by ticking the box below. If you change your mind later, you can alter your opt out option via the ‘Edit my Profile’ link under Advanced Services.
</td>
</tr-->
<tr>
<td>
 </td>
<td>
 </td >
<td>
<asp:CheckBox ID="chkOptOut" runat="server" Text="  By submitting this registration form, you will be indicating your consent to receiving email marketing messages from us <strong>unless</strong> you have indicated an objection to receiving such messages by ticking this box." />
</td>
</tr>


<tr>
<th colspan="3" class="head">
<h2>
CAPTCHA VERIFICATION</h2>
</th>
</tr>
<tr>
<td>
 </td>
<td>
 </td>
<td>

<recaptcha:RecaptchaControl ID="RecaptchaControl" runat="server" PublicKey=""
PrivateKey="" Theme="white" />

<asp:CustomValidator ID="CustomValidator2" OnServerValidate="ValidateRecaptcha" ValidationGroup="CreateUserWizard1"
runat="server" ForeColor="Red" SetFocusOnError="true"/> <asp:Label ForeColor="Red" runat="server" ID="lblCapatchaError"/>


</td>
</tr>

<tr>
<th colspan="3" class="head">
<h2>
DATA PROTECTION DECLARATION</h2>
</th>
</tr>
<tr>
<td colspan="3">
<p>
Sanlam Life & Pensions UK Limited and Sanlam Financial Services UK Limited
are both registered as data controllers in their own right. Both companies
will act as data controller in respect of the personal data which you provide. The
information provided by you may be held by Sanlam Investments and Pensions (the name used as
reference to both Sanlam Life & Pensions UK Limited and Sanlam Financial
Services UK Limited) for purposes in connection with the contract (and related
services) for which you have applied.</p>
<p>
You understand that any personal information you provide to Sanlam Investments and Pensions
will be processed by us in accordance with the Data Protection Act 1998. You agree that
your personal information may be used by Sanlam Investments and Pensions for business analysis,
relationship management and administration, and may be passed within the Sanlam group of companies
for those reasons. You understand that, if necessary,
Sanlam Investments and Pensions will pass your details onto regulatory authorities or other third
parties, as may be required by law.</p>
</td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:CreateUserWizardStep>
<asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">
<ContentTemplate>
<h2>
Application for on-line services</h2>
<p>
Your application for on-line services has been received. A confirmation email will
be sent to the address you have supplied. Once you receive this email you can access
our on-line services.</p>
<p>
If you have any questions regarding our on-line services, please call our Client
Support team on 0117 975 2355 or email the team at <a href="mailto://ifapartners@sanlam.co.uk">ifapartners@sanlam.co.uk</a>.
</p>
</ContentTemplate>
</asp:CompleteWizardStep>
</WizardSteps>
<FinishNavigationTemplate>
<asp:Button ID="FinishPreviousButton" runat="server" CausesValidation="False" CommandName="MovePrevious"
Text="Previous" />
<asp:Button ID="FinishButton" runat="server" CommandName="MoveComplete" Text="Finish"
Visible="false" />
</FinishNavigationTemplate>
</asp:CreateUserWizard>

and codebehind (sorry it's .vb, it's inherited!)
Imports CMS.PortalControls
Imports CMS.FormEngine
Imports CMS.CMSHelper
Imports CMS.GlobalHelper
Imports CMS.SiteProvider.UserInfo
Imports CMS.EmailEngine
Imports System.Web

Partial Class CMSWebParts_Membership_MemSvcsRegister
Inherits CMSAbstractWebPart

Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As System.EventArgs) Handles CreateUserWizard1.CreatedUser

' process

End Sub


'Our custom server validator's validation method, to use for a validation group

Protected Sub ValidateRecaptcha(ByVal sender As Object, ByVal e As ServerValidateEventArgs)

Dim reControl As Recaptcha.RecaptchaControl

reControl = DirectCast(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("RecaptchaControl"), Recaptcha.RecaptchaControl)

reControl.Validate()

'Show or hide error messages
If Not reControl.IsValid() Then
DirectCast(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("lblCapatchaError"), Label).Text = " * Please enter a valid CAPTCHA"
DirectCast(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("lblCaptchaSummaryError"), Label).Text = " * A valid CAPTCHA is required"
Else
DirectCast(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("lblCapatchaError"), Label).Text = ""
DirectCast(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("lblCaptchaSummaryError"), Label).Text = ""

End If

End Sub

End Class

User avatar
Member
Member
rob.nisbet-sanlam - 1/16/2013 5:37:48 AM
   
RE:Google reCAPTCHA in a BizForm : tutorial
Hi Gavin, just wondered if you had any luck with that unholy mess of code I posted :)
hanks
Rob

User avatar
Member
Member
rob.nisbet-sanlam - 1/16/2013 7:54:26 AM
   
RE:Google reCAPTCHA in a BizForm : tutorial
Found the issue.

Google renders the result of the control on the page as :
<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=6Le6LsgSAAAAAF3lY6aVc30w_PKshCEH_SQ1jk9o"  >
</script>

however Kentico 7 has a problem with scripts (when the type= tag is before the src= tag.

If I manually create the above with src= first, I get the CAPTCHA.

User avatar
Member
Member
Gavin_Paolucci-Kleinow-URMC - 1/16/2013 8:41:56 AM
   
RE:Google reCAPTCHA in a BizForm : tutorial
Rob,
I'm sorry I didn't get back to you. I don't have an instance of Kentico 7 setup, so I wasn't able to test out your code, but looking through your code I wasn't able to find anything wrong. I'm glad you figured it out. Again, sorry I wasn't a help.

User avatar
Member
Member
davids-kentico - 1/21/2013 5:27:39 AM
   
RE:Google reCAPTCHA in a BizForm : tutorial
Hey guys,

just a quick tease - reCaptcha will be available out of the box in the next version ;)

User avatar
Member
Member
mhill - 8/13/2013 11:50:33 AM
   
RE:Google reCAPTCHA in a BizForm : tutorial
Do you know which version that will be out of the box for? we are 7.0.19.

Thanks.

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 8/13/2013 2:45:14 PM
   
RE:Google reCAPTCHA in a BizForm : tutorial
Hi,

David was talking about the next major version which will be released at the of year 2013 -Kentico 8.

Regards,
Martin Danko