﻿ var __IsCaptchaEnable = false;
 var __DropZoneID ='';
 function checkValid(){            
            // for Ektron form validation: use your FormBlock's client ID
            var FormIsValid = EkFmValidate(document.getElementById(__DropZoneID));
            if(FormIsValid)
            {             
                if(__IsCaptchaEnable)
                {
                    var captchaValidate=false;
                    captchaValidate = validateCaptcha();
                    if(captchaValidate==false)
                    {
                        return false;
                    }
                }
                Ektron.FormBlock.setTargetAction("postback");
                Ektron.FormBlock.setState("__ekFormState", "in");
                return true;
            }
            else {
                return false;
            }
        }
        function validateCaptcha()
        {
            challengeField = $("input#recaptcha_challenge_field").val();
            responseField = $("input#recaptcha_response_field").val();
            if(responseField!="")
            {
                var html = $.ajax({
                type: "POST",
                url: "/pages/ajax_recaptcha.aspx",
                data: "recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField,
                async: false
                }).responseText;
                
                if(html == "True")
                {               
                    return true;
                }
                else
                {
                    Recaptcha.reload();
                    alert("Enter the correct letters as they are shown in the image...");
                    return false;
                }
            }
            else
            {
                alert("Enter the letters as they are shown in the image...");
                return false;
            }
        }
