Search code examples
asp.net-mvccaptchaajaxform

Vyacheslav Captcha validation on Ajax post not working


I have this following code in Razor view

 @{
                var captcha = Html.Captcha("", "Enter the text you see above:", 5, "", false);
            }
            <div style="float:left;">
                @captcha
                @Html.ValidationMessage(captcha.BuildInfo.InputElementId)
            </div>

And in the Controller following code is there :

var isValidCaptcha = this.IsCaptchaValid("Captcha is not valid");
                if (!isValidCaptcha)
                {
                    validationErrorslist.Add("Captcha is not valid");
                    return new JsonResult { Data = new { IsSuccess = false, Message = validationErrorslist } };
                }

Only first time validation is working, but for the second time it is referring to the old value only.. Example : If I gave wrong captcha it is showing as invalid captcha, next time if I correct and submit the page I am still getting invlid catpcha message.

What I am missing here...thanks in advance..


Solution

  • This link from codeplex solved my problem http://captchamvc.codeplex.com/discussions/430792