so here I will include the html and JS code. Kindly suggest what changes or modifications should I do so that the recaptcha works for the multiple forms submit
<button class="spec" data-toggle="modal" th:data-target="'#exampleModal_'+${mou.productCatalogId}">
Datasheet
</button>
the above button is to trigger the modals based on productCatalogId
<div th:each="mou,iterationStatus: ${productCatalogImplList}">
<div class="modal left fade" th:id="'exampleModal_'+${mou.productCatalogId}" tabindex="-1"
aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog w-100">
<div class="modal-content manufacturerModal">
<div class="modal-header manufacturerModalHeader border-0">
<h5 class="modal-title text-dark manufacturerModalh5"
id="exampleModalLabel">Please Tell Us More About Yourself</h5>
<button type="button" class="close py-1 closeMobView"
data-dismiss="modal" aria-label="Close">
<span aria-hidden="true" class="close-times2">×</span>
</button>
</div>
<div class="modal-body pt-0 manufacturerModalBody" th:id="'manufacturerPopUp'+${manufacturer.manufacturerId}" >
<blc:form name="bridgeluxBroucher" th:id="'bridgeluxBroucher_'+${mou.productCatalogId}"
action="/submitBroucherEnquiryForm2" method="POST">
<div>
<div class="form-group col px-0">
<input type="hidden" name="manufacturerId"
th:value="${mou.manufacturerIdEncrypted}" />
<input type="hidden" name="categoryId"
th:value="${mou.categoryIdEncrypted}" />
<input type="hidden" name="typeBroucher" value="About Us" />
<input type="hidden" name="manufacturerName" th:value="${manufacturer.manuFacturerName}" />
<input type="hidden" name="mainCategoryName" th:value="${mainSubCatagoryBredScrumb.mainCategoryName}" />
<input type="hidden" name="mainSubCategoryName" th:value="${mainSubCatagoryBredScrumb.mainSubCategoryName}" />
<input type="hidden" name="categoryName" th:value="${categoryName}" />
<input type="hidden" name="manufacturerPartBroucher" th:value="${mou.manufacturerPart}" />
<input type="hidden" name="dataSheet" th:id="'dataSheetUrl'+${mou.productCatalogId}"
th:value="${mou.dataSheet}" />
<label>Name <b><span class="pencil-dashboard">*</span></b></label>
<input type="text" class="form-control" name="nameBroucher"
th:id="'nameBroucher_'+${mou.productCatalogId}" th:value="${session.customer.fullName}" readonly/>
</div>
</div>
<div class="g-recaptcha" data-sitekey="6LeEWI8aAAAAAJd1hEk72AGlDtvAHVO6uuyzjv3V" >
</div>
<input type="hidden" name="authBroucher" id="authBroucher"/>
<input type="hidden" name="selectrecaptchabroucher" id="selectrecaptchabroucher" value="0"/>
<div class="modal-footer border-0 px-0 mt-5 pt-5 pb-0">
<button type="button" id="mfrKnowMore"
th:onclick="'broucherFormSubmit('' + ${mou.productCatalogId} + '');'" class="details">Submit</button>
</div>
</blc:form>
</div>
</div>
</div>
</div>
</div>
so above is my modal inside which I have a form and google recaptcha corresponding to each productCatalog which are dynamically generated
function checkBroucherRecaptcha() {
var response = grecaptcha.getResponse();
document.getElementById("authBroucher").value=response;
if(response.length == 0) {
alert("no pass");
}
else {
document.getElementById("selectrecaptchabroucher").value=1;
}
}
function broucherFormSubmit(productCatalogId) {
checkBroucherRecaptcha();
var form = document.getElementById("bridgeluxBroucher_" + productCatalogId);
var valid = 1;
if (document.getElementById("nameBroucher_" + productCatalogId).value == "") {
alert("Please enter name");
document.getElementById("nameBroucher_" + productCatalogId).focus();
return false;
valid = 0;
}
if(document.getElementById("selectrecaptchabroucher").value==0){
alert("Please confirm you are not robot");
document.getElementById("selectrecaptchabroucher").focus();
return false;
valid = 0;
}
if (confirm("are you sure you want to submit?")) {
if (valid == 1) {
form.submit();
}
}
}
above is my JS code. Kindly suggest what should I do so that every form is getting submitted after checking the recaptcha as it’s not working for every form. I know I have included a lot of content just for better understanding.