Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Captcha > Client-side validation

Not answered Client-side validation

Feed from this thread
  • Posted on Jan 22, 2010 (permalink)

    Hi,

    Is it possible to validate on the client through

    <asp:CustomValidator CssClass="Error Akkoord" ValidationGroup="Weblink"  ClientValidationFunction="Captcha" Runat="server" display="none" ID="CaptchaReq"/>

    <script language="javascript">
    function Captcha(oSrc, args)
    {
    //Validate the Captcha object here
    }
    </script>

    Thanks,
    Marc



    <script language="javascript">
    function Captcha(oSrc, args)
    {
    $(document.getElementById("<%=SoortBedrijf.ClientID%>")).addClass("PaginaError");
      if ( document.getElementById("<%= SoortBedrijf.ClientID %>")!=null &&
         document.getElementById("<%= SoortBedrijf.ClientID %>").childNodes!=null)
         {
            for (var i=0;i<document.getElementById("<%= SoortBedrijf.ClientID %>").getElementsByTagName("input").length ; i++)
            {
               if ( document.getElementById("<%= SoortBedrijf.ClientID %>").getElementsByTagName("input")[i].checked )
               {
               $(document.getElementById("<%=SoortBedrijf.ClientID%>")).removeClass("PaginaError");
              args.IsValid = true;
             return true;
               }
               else
               {args.IsValid = false;
               return false;
               }
          }
       }
    }
    </script>   


    Reply

  • Pero Pero admin's avatar

    Posted on Jan 25, 2010 (permalink)

    Hi Marc,

    RadCaptcha performs only server-side validation. The RadCaptcha code cannot be accessed from the client and thus client-side validation cannot be performed.

    Please do not hesitate to contact us, if you have any further questions.

    Sincerely yours,
    Pero
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

    Reply

  • Mark Ursino avatar

    Posted on Feb 1, 2010 (permalink)

    Would it be possible to create either a web service or a handler that takes in the user input and the Captcha GUID and performs server-side validation in that? Then you could make an AJAX call to that validator and you'd achieve client-side validation from that?

    Reply

  • Pero Pero admin's avatar

    Posted on Feb 4, 2010 (permalink)

    Hello Mark,

    The page goes through its full life-cycle on AJAX calls: http://encosia.com/2007/10/24/are-you-making-these-3-common-aspnet-ajax-mistakes/. This means that a new RadCaptcha code will be generated but it would not be displayed on the image, since the RadCaptcha control is not updated by the AJAX call. Basically you would compare the old code with the new code and the user input will always be validated as wrong.

    One more thing is that this would create additional load on the server because there would be an additional trip to the server just to validate the Captcha code.

    Regards,
    Pero
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.

    Reply

  • Posted on May 9, 2011 (permalink)

    The reason client-side validation of a CAPTCHA is desirable is because there may be RadUpload controls on the same page. If the person has mistyped the CAPTCHA, then they have to wait until all of their uploads have completed just to find out they did it wrong, and then the file uploads as well as the time taken are lost.

    Reply

  • Pero Pero admin's avatar

    Posted on May 10, 2011 (permalink)

    Hi Ross,

    For this scenario our suggestion is to place the RadCaptcha in an Ajax Panel and perform an Ajax request to test for the entered code. After the user has entered a valid string, then you can allow her (him) to upload the files.

    Best wishes,
    Pero
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Captcha > Client-side validation