I want to add captcha validation while registering the user. I am using p:captcha
. The keys are setup properly, and I can see captcha in my local machine. But on server, after validating captcha and clicking on submit the captcha resets and gives error:Please validate Captcha.
(requiredMessage below) and stays on same page.
It does not hit my controller on server. Do we have to do some settings on server? However, it works fine on my local machine. On server, no logs, no errors.
Fresh Captcha showing on page:
After validating:
After clicking on submit: (The captcha resets. It doesn’t hit my backend controller, just stuck on same page)
I have a captcha defined below:
register.xhtml
file:
<ui:define name="content">
<h:form id="registerForm">
<div class="card-body">
<ui:include src="userDetails.xhtml" />
<p:commandButton
type="submit" styleClass="float-end" value="Submit"
update="@form" process="@form" icon="pi pi-chevron-circle-right"
id="sign-up-button" escape="false" actionListener="#Cntrl.submit}"
ajax="false" />
</div>
</h:form>
</ui:define>
File userDetails.xhtml
:
<div class="col-md-6">
<ui:define name="control">
<p:captcha
label="Captcha" id="captcha" required="true"
requiredMessage="Please validate Captcha."
validatorMessage="Please validate Captcha." />
<p:message for="captcha" escape="false" />
</ui:define>
</div>