RadCaptcha Not Validating

8 posts, 0 answers
  1. Prathap Narravula
    Prathap Narravula avatar
    23 posts
    Member since:
    Apr 2010

    Posted 02 Nov 2010 Link to this post


    I am doing booking form page for the members with Radcaptch validation.


    <telerik:RadCaptcha ID="RadCaptcha1" runat="server" ValidationGroup="SubmitInfo"



       ErrorMessage="The code you entered is not valid." Display="Dynamic">





    I given the ValidationGroup Property to textbox requiredfield validation and  submit button also.

    RequiredFieldValidator is validating for textbox but radcaptch is not validating


    <asp:TextBox ID="txtemail" runat="server"></asp:TextBox>



    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ValidationGroup="SubmitInfo"



    runat="server" ControlToValidate="txtemail" ErrorMessage="Enter Email"></asp:RequiredFieldValidator>



    <asp:Button ID="btnbooking" runat="server" ValidationGroup="SubmitInfo" Text="Submit"



    OnClick="btnbooking_Click" />

    Please help in the issue which i stucked for 3 days.

    Urgent reply highly appreciable

    Prathap Narravula


  2. Pero
    Pero avatar
    1156 posts

    Posted 04 Nov 2010 Link to this post

    Hi Prathap,

    Could you please explain in more detail what do you mean by "RadCaptcha is not validating"?

    Please note that the RadCaptcha control does not support client-side validation. A post back to the server is needed in order for the Captcha to perform validation. So if at first sight it seems that the Captcha does not validate, but the other validators do, it is because the they also support client-side validation and prevent the WebForm from submitting if the page is not valid.

    In case you check for the IsValid property on the server, in the button's click event handler, then you should call RadCaptcha's Validate and Page's Validate(ValidationGroup), to be sure that validation has occurred, before checking the IsValid flag.

    Note that if you dynamically create the Captcha control, you must add it to the page on every postback, and before the ViewState is loaded. That is if you add the control in the Page.Load, it is too late, because the ViewState has been loaded, and the Captcha will always invalidate the code. Our suggestion is to use the Page.Init method instead.

    All the best,
    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. Danny
    Danny avatar
    7 posts
    Member since:
    Jan 2012

    Posted 22 Feb 2012 Link to this post

    You must:

    • Enter value for ErrorMessage property
    • ValidationGroup must match the ValidationGroup name on the ValidationSummary and the button that causes the PostBack.
    • The button causing the PostBack must have CausesValidation set to true.


    Remember that the RadCaptcha does NOT have client-side validation like many of the other controls on your page.  You will not see RadCaptcha validation until the page is posted back to the server.   Other controls that have client-side validation will warn user of errors without posting the page back to the server which means your RadCaptcha wont validate at that point.   This may give the appearance that your RadCaptcha validation is not working. 


  4. Glenn
    Glenn avatar
    5 posts
    Member since:
    Oct 2012

    Posted 30 Aug 2013 Link to this post

    Is there a way to use the RequiredFieldValidator?  I would like to prevent a postback if the user hasn't entered anything into the captcha code text box.
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Sep 2013 Link to this post

    Hi Glenn,

    You can validate the RadCaptcha via a custom RadTextBox and give an ASP RequiredFieldValidator to the particular RadTextBox to prevent the postback if it is empty. The custom RadTextBox for RadCaptcha can be given by

    1. Setting the propery CaptchaImage.RenderImageOnly to true to render only the captcha image without the TextBox and Label of the control.

    2. Setting the property ValidatedTextBoxID to the ID of the RadTextBox which you want to use for entering the RadCaptcha code.

    Please have a look at the following code I tried which works fine at my end.


    <telerik:RadCaptcha ID="RadCaptcha1" runat="server" ErrorMessage="Invalid Captcha"
        IgnoreCase="true" CaptchaImage-RenderImageOnly="true" ValidatedTextBoxID="RadTextBox1">
    <br />
    <telerik:RadTextBox ID="RadTextBox1" runat="server">
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*"
        ForeColor="Red" ControlToValidate="RadTextBox1"></asp:RequiredFieldValidator>
    <br />
    <telerik:RadButton ID="RadButton1" runat="server" Text="Submit" CausesValidation="true"

  6. Glenn
    Glenn avatar
    5 posts
    Member since:
    Oct 2012

    Posted 03 Sep 2013 Link to this post

    I tried that and what happens is that the textbox gets blanked out before the requiredfieldvalidator fires so it never actually does a postback.  I was able to add a "hidden" textbox and add an onblur event to the actual textbox to copy the code to the hidden one.  I tied the requiredfieldvalidator to the hidden textbox.  That was the only way I could get it to work.
  7. Slav
    Slav avatar
    1359 posts

    Posted 06 Sep 2013 Link to this post

    Hello Glenn,

    Usually the validated textbox gets cleared after the postback, so it is strange that this happens even before the RequiredFieldValidator validates the input. I would suggest checking if there is a custom client-side script that clears the textbox before validation. Also, you can send a fully runnable sample that isolates your scenario and I will do my best to locate the cause of the issue.

    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  8. Dhamodharan
    Dhamodharan avatar
    300 posts
    Member since:
    Sep 2010

    Posted 20 Sep 2013 Link to this post

    Hi Glenn,
    please try the following coding on client button clicking event.
    Declare a label - lblCaptchaErr to display the error msg
    Assume your Captcha named as RadCaptcha1

    On button clicking event
       if (document.getElementById('RadCaptcha1_CaptchaTextBox').value == "") {                   
                        document.getElementById('<%= lblCaptchaErr.ClientID %>').innerHTML = "Please enter the Captcha Code";


Back to Top