Captcha not working

4 posts, 0 answers
  1. Jun Ting
    Jun Ting avatar
    26 posts
    Member since:
    Nov 2007

    Posted 05 May 2010 Link to this post

    The captcha is not working. The "t2" (Message that i want to show after submit the form)  still showing althrough i enter the wrong code.


    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="pe_test2.aspx.vb" Inherits="pe_test2" %> 
     
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml">  
    <head runat="server">  
        <title></title>  
    </head> 
    <body> 
        <form id="form1" runat="server">  
        <div> 
            <telerik:RadScriptManager runat="server" ID="RSM">  
            </telerik:RadScriptManager> 
              <table border="0" cellpadding="5" cellspacing="0" style="background: #FFFFFF;" width="100%">  
                <tbody> 
                    <tr valign="top"><td width="20%" class="textForm">  
                         <b>Name *</b>    
                        </td> 
                        <td style="margin-left: 40px">  
                          <telerik:radtextbox id="txtFullName_E" runat="server" width="435">  
                            <enabledstyle letterspacing="1px" paddingbottom="5px" paddingleft="5px"   
                                paddingright="5px" paddingtop="5px" backcolor="#FFFFFF" borderstyle="Solid"   
                                font-bold="True" font-size="14px" bordercolor="#DCDCDC"   
                                borderwidth="3px" /> 
                                <focusedstyle bordercolor="#ff3c00" borderwidth="3px" /> 
                        </telerik:radtextbox> 
                       <br /> 
       <asp:RequiredFieldValidator ID="RFVtxtFullName_E" runat="server" ErrorMessage="Please enter your name." ValidationGroup="Ein" 
                            ControlToValidate="txtFullName_E" Display="Dynamic" Font-Size="12px">Please enter your name.</asp:RequiredFieldValidator> 
                        </td> 
                    </tr> 
                        <tr valign="top">  
                        <td class="textForm">  
                           <b> Email *</b> 
                        </td> 
                        <td> 
                         
                         <telerik:radtextbox id="txtEmail_E" runat="server" width="435" emptymessage="yourname@domain.com">  
                            <enabledstyle letterspacing="1px" paddingbottom="5px" paddingleft="5px"   
                                paddingright="5px" paddingtop="5px" backcolor="#FFFFFF" borderstyle="Solid"   
                                font-bold="True" font-size="14px" bordercolor="#DCDCDC"   
                                borderwidth="3px" /> 
                                <focusedstyle bordercolor="#ff3c00" borderwidth="3px" /> 
                        </telerik:radtextbox> 
                    <br /> 
     
                    <asp:RequiredFieldValidator ID="RFVtxtEmail_E" runat="server" ControlToValidate="txtEmail_E" Display="Dynamic" ErrorMessage="Please enter your email address." Font-Size="12px" ValidationGroup="Ein" 
                        >Please enter your email address.</asp:RequiredFieldValidator> 
                          
                        <asp:regularexpressionvalidator errormessage="Please enter a valid email address" display="Dynamic" runat="server" controltovalidate="txtEmail_E" validationexpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" ValidationGroup="Ein" 
                                            id="REVtxtEmail_E" Font-Size="12px">Please enter a valid email address</asp:regularexpressionvalidator> 
                        </td> 
                    </tr> 
                      
                     
                  
                </tbody> 
            </table> 
              
              <div class="OrangeBar" style="margin-top: 5px;margin-bottom:5px;">  
                Step 2: Your Enquiry  
            </div> 
             <table border="0" cellpadding="5" cellspacing="0" style="background: #FFFFFF;" width="100%">  
                <tr valign="top">  
                    <td width="20%" class="textForm">  
                      <b>Enquiry *</b>    
                    </td> 
                    <td> 
                     <telerik:radtextbox id="txtEnquiry_E" runat="server" width="435" Height="100px" TextMode="MultiLine">  
                            <enabledstyle letterspacing="1px" paddingbottom="5px" paddingleft="5px"   
                                paddingright="5px" paddingtop="5px" backcolor="#FFFFFF" borderstyle="Solid"   
                                font-bold="True" font-size="14px" bordercolor="#DCDCDC"   
                                borderwidth="3px" /> 
                                <focusedstyle bordercolor="#ff3c00" borderwidth="3px" /> 
                        </telerik:radtextbox><br /> 
                          <asp:RequiredFieldValidator ID="RFVtxtEnquiry_E" runat="server" ErrorMessage="Please enter your enquiry." ValidationGroup="Ein" 
                            ControlToValidate="txtEnquiry_E" Display="Dynamic" Font-Size="12px">Please enter your enquiry.</asp:RequiredFieldValidator> 
                          
                    </td> 
                </tr> 
                    <tr valign="top">  
                    <td> 
                        &nbsp;  
                    </td> 
                    <td> 
                      <br /> 
                        <strong>Please enter the code shown above for security  
                            validation. *</strong> 
                        <br /> 
                        <em class="font08">(Note: This is case sensitive.)</em><br /> 
                     
                             <telerik:RadCaptcha ID="RadCaptcha_E" runat="server"   
                        ErrorMessage="Please enter the code shown correctly." CaptchaTextBoxLabel="" Display="Dynamic" ValidationGroup="Ein">  
                        </telerik:RadCaptcha> 
                         
                    </td> 
                </tr> 
                  <tr valign="top" class="">  
                    <td> 
                        &nbsp;  
                    </td> 
                    <td> 
                        
                        <asp:ImageButton ID="btnSubmit_E" ValidationGroup="Ein" ImageUrl="images/button_submit.gif" runat="server" ToolTip="Submit" /> 
                        <br /> 
                        <asp:ValidationSummary ID="ValidationSummary2" ValidationGroup="Ein" runat="server" 
                            ShowMessageBox="True" ShowSummary="False" /> 
                    </td> 
                </tr> 
                  
             </table> 
            <table width="100%" border="0" cellpadding="0" cellspacing="0" id="t2" runat="server" 
                visible="false">  
                <tr> 
                    <td> 
                        Testing, testing........  
                    </td> 
                </tr> 
            </table> 
        </div> 
        </form> 
    </body> 
    </html> 
     
    Imports System.Data  
    Imports Telerik.Web.UI  
    Imports System.IO  
     
    Partial Class pe_test2  
        Inherits System.Web.UI.Page  
     
        Protected Sub btnSubmit_E_Click(ByVal sender As ObjectByVal e As System.Web.UI.ImageClickEventArgs) Handles btnSubmit_E.Click  
            t2.Visible = True 
        End Sub 
    End Class 
  2. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 05 May 2010 Link to this post

    Hello Jun,

    RadCaptcha does not perform client-side validation (security reasons). So the page must be submitted in order for the code entered to be validated. Please use RadCaptcha.IsValid property to check whether the correct code is entered, and then display the message.

    The code behind should look like the following:

    Protected Sub btnSubmit_E_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnSubmit_E.Click
        If RadCaptcha_E.IsValid Then
            t2.Visible = True
        Else
            t2.Visible = False
        End If
     
    End Sub



    Regards,
    Pero
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tommy
    Tommy avatar
    23 posts
    Member since:
    Jun 2009

    Posted 12 Jul 2010 Link to this post

    So, in order to make the captcha work in it's most basic use, you have to use an If/THEN statement to check its validity right? Such as, if it's valid, do whatever your form is supposed to do, else return an error message...
  5. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 14 Jul 2010 Link to this post

    Hello Tommy,

    Yes if you want to execute a custom code depending on whether the Captcha is valid or not, you should use the RadCaptcha's IsValid property. Another more general way is to check whether the page has passed validation is to check Page.IsValid property, and then execute your custom source code.

    All the best,
    Pero
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top