Client-side validation

7 posts, 0 answers
  1. Fit2Page
    Fit2Page avatar
    345 posts
    Member since:
    Feb 2007

    Posted 22 Jan 2010 Link to this post

    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>   


  2. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 25 Jan 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mark Ursino
    Mark Ursino avatar
    4 posts
    Member since:
    Feb 2010

    Posted 01 Feb 2010 Link to this post

    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?
  5. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 04 Feb 2010 Link to this post

    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.
  6. Ross Presser
    Ross Presser avatar
    30 posts
    Member since:
    Dec 2008

    Posted 09 May 2011 Link to this post

    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.
  7. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 10 May 2011 Link to this post

    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.

  8. Morten
    Morten avatar
    267 posts
    Member since:
    Jul 2012

    Posted 12 Dec 2013 Link to this post

    You could check for entry into the captcha textbox using jquery:

    <telerik:RadCaptcha runat="server" ID="rcCode"></telerik:RadCaptcha>

    <asp:CustomValidator runat="server" ID="cusCode" ControlToValidate="DummyTextBox" ClientValidationFunction="ValidateCaptchaEntry"></asp:CustomValidator>

    <asp:ValidationSummary runat="server"     ID="vs" ShowMessageBox="true" ShowSummary="false" />

            function ValidateCaptchaEntry(sender, args) {
                var formValid = true;
                if ($("[id$='rcCode_CaptchaTextBox']").val().length == 0) {
                    sender.errormessage = 'Repeat code';
                    formValid = false;
                }
                args.IsValid = formValid;
            }
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017