Open blovia22 opened 2 years ago
I also have this issue in windows 10, chrome.
I would have thought it would still do client side validation?
I found a workaround for this, after spending more time getting my head around recaptcha3.
I added the following script to ensure if would
`$(document).ready(function () {
$("#submitButton").click(function (event) {
event.preventDefault();
if ($("#frmUserNameEntry").valid()) {
var recaptchaWait = setInterval(() => {
if ($("input[name='g-recaptcha-response']:first").val() == "") {
console.log("recaptcha not ready");
}
else {
console.log("recaptcha ready to proceed.");
clearInterval(recaptchaWait);
document.forms[0].submit();
}
}, 100);
}
else {
console.log("form errr");
}
});
});`
Describe the bug If I fill out all the fields of my form, except the captcha, there is no client side validation. The browser goes to the server, where I can use ModelState.IsValid to find the error. But I would like to prevent the browser going to the server.
To Reproduce Steps to reproduce the behavior:
builder.Services.AddReCaptcha(builder.Configuration.GetSection("ReCaptcha"));
@using AspNetCore.ReCaptcha
and@Html.ReCaptcha()
(this one inside the form)[ValidateReCaptcha]
just abovepublic class contactModel : PageModel
OnPost()
action, addExpected behavior It would be nice to have an option to add an
asp-validation-for
tag or anasp:RequiredFieldValidator
tag in order to add client-side validation for the captcha.Or is there a way with javascript to check that the captcha was solved and if it wasn't, show a red message below the captcha without having the browser go back to the server?
Desktop (please complete the following information):