Hi again, I have one more question about the contact section form in Umazel Starter Kit Theme.
I have tried to add a reCaptcha to the view but I don't know how to catch the reCaptcha error messages and present them in the view probably by using javascript.
This is the controller
[HttpPost]
[NotChildAction]
public ActionResult Submit(ContactViewModel form)
{
RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();
if (string.IsNullOrEmpty(recaptchaHelper.Response))
{
ModelState.AddModelError("reCAPTCHA", "Please complete the reCAPTCHA");
return CurrentUmbracoPage();
}
else
{
RecaptchaVerificationResult recaptchaResult = recaptchaHelper.VerifyRecaptchaResponse();
if (recaptchaResult != RecaptchaVerificationResult.Success)
{
ModelState.AddModelError("reCAPTCHA", "The reCAPTCHA is incorrect");
return CurrentUmbracoPage();
}
}
if (!ModelState.IsValid)
{
return Json(new { Success = false });
}
And a think I have to add the messages in the script part of the view
<script type="text/javascript">
function ShowContactError() {
$(".errorContent").show();
$("#contactFormHolder").hide();
}
function ShowContactSuccess(arg) {
if (arg.Success === true) {
$("#contactSuccess").show();
$("#contactFormHolder").hide();
}
else
{
$(".successContent").show();
$("#contactFormHolder").hide();
}
}
Adding reCaptcha in the Contact section
Hi again, I have one more question about the contact section form in Umazel Starter Kit Theme.
I have tried to add a reCaptcha to the view but I don't know how to catch the reCaptcha error messages and present them in the view probably by using javascript.
This is the controller
And a think I have to add the messages in the script part of the view
BR Inge Wihlborg
Did you download recaptcha element by nuget or how did you added to project?
Yes I did download the recaptcha from nuget.
is working on a reply...