Recently I developed a page that has html and razor, in it I have an @ html.Captcha like the following:
@Imports CaptchaMvc.HtmlHelpers
@Html.Captcha("Refrescar", "Por favor, escriba el texto de la imagen.", 5, "Is required field.", True)
The problem occurs when I load the page for the first time, I write the text of the generated image correctly but it still indicates that the text is incorrect, then I write it again and it is validated correctly.
The result is an error handled by jquery.validate:
Also in my jquery file only the following is valid:
$('form').validate({
rules: {
CaptchaInputText: {
required: true
}
},
highlight: function (element) {
$(element).closest('.form-group').addClass('has-error');
$('#validarDatos').prop("disabled", true);
},
unhighlight: function (element) {
$(element).closest('.form-group').removeClass('has-error');
$('#validarDatos').prop("disabled", false);
},
errorElement: 'span',
errorClass: 'help-block',
errorPlacement: function (error, element) {
if (element.parent('.input-group').length) {
error.insertAfter(element.parent());
} else {
error.insertAfter(element);
}
}
});// fin form.validate