Home » Javascript » Two forms on a single page with capcha, html5 form validation is not working anymore

Two forms on a single page with capcha, html5 form validation is not working anymore

Posted by: admin August 19, 2018 Leave a comment

Questions:

I am currently using two forms on a single page with a generated function to submit the invisible recaptcha with its token.

One of the problems is that the html5 form validation is not working anymore, it ignores the “required” tags on the input fields.

#sFormId# holds the form ID of the current form in an array.

<button id="#sFormId#submit-button" class="button small expand g-recaptcha" data-sitekey="xyz" data-callback="Submit#sFormId#" value="">submit</button>
function Submit#sFormId#(token){
  document.getElementById("#sFormId#").submit();
}

Another problem i am having is that the two forms are in seperate divs that toggle each other. The captcha badge is visible if the first form is open but once i toggle the other div to open the badge disappears with the first badge.

Answers: