0

I am using CaptchaMvc.Mvc5 in my application. I am sending captcha and other form details via ajax to controller. If captcha is wrong , then I am returning to the same page from ajax result and not reloading the page from controller.

Till this everything works fine. Captcha Validation is working properly.

But once returned to the page from javascript, the captcha is not working properly. Even refresh captcha which comes by default with it is not working.

I am doing some validations in JS, so not able to submit the form. Is there any way that I can make the captcha to work again in the same page?

HTML

@Html.Captcha(5)

JS

$.ajax({
            url: '/Controller/ValidateCaptcha',
            type: 'POST',
            data: $("#Form").serialize(),
            success: function (result) 
             {
                if (result == "False") 
                {
                    return;   // return back to the page without reloading it.
                }
            },
            error: function (err) 
            {
            }
        });    

Controller

        [HttpPost]
        public bool ValidateCaptcha(FormDetails data)
        {
            var res = this.IsCaptchaValid("") ? true: false;
             //Will be doing some other validations also.
            return res;
        }
Archana
  • 75
  • 8

0 Answers0