SamPo Posted August 26, 2021 Report Share Posted August 26, 2021 Hello, I have the below code in the footer of a submission datapage, however in some circumstances it is bringing up multiple alert windows with the same message, one after the other. I've probably made a simple error somewhere in the coding, could anyone help? <script> document.addEventListener('BeforeFormSubmit', function(event) { if (event.detail.appKey == 'xxxxxxxxxxxxxxxxxxx') { let checkValue1 = document.querySelector("input[id*='InsertRecordno_of_selections_qty1']").value; if (checkValue1 > '1') { event.preventDefault(); alert("There too many lines selected for Qty 1"); return false; } } if (event.detail.appKey == 'xxxxxxxxxxxxxxxxxxx') { let checkValue2 = document.querySelector("input[id*='InsertRecordno_of_selections_qty2']").value; if (checkValue2 > '1') { event.preventDefault(); alert("There too many lines selected for Qty 2"); return false; } } if (event.detail.appKey == 'xxxxxxxxxxxxxxxxxxx') { let checkValue3 = document.querySelector("input[id*='InsertRecordno_of_selections_qty3']").value; if (checkValue3 > '1') { event.preventDefault(); alert("There too many lines selected for Qty 3"); return false; } } if (event.detail.appKey == 'xxxxxxxxxxxxxxxxxxx') { let checkValue4 = document.querySelector("input[id*='InsertRecordno_of_selections_qty4']").value; if (checkValue4 > '1') { event.preventDefault(); alert("There too many lines selected for Qty 4"); return false; } } if (event.detail.appKey == 'xxxxxxxxxxxxxxxxxxx') { let checkValue5 = document.querySelector("input[id*='InsertRecordno_of_selections_qty5']").value; if (checkValue5 > '1') { event.preventDefault(); alert("There too many lines selected for Qty 5"); return false; } } }); </script> Quote Link to comment Share on other sites More sharing options...
TellMeWhy Posted August 26, 2021 Report Share Posted August 26, 2021 Try putting this after the addeventlistener line event.stopImmediatePropagation(); If it does not work, try putting it inside every 'if' SamPo 1 Quote Link to comment Share on other sites More sharing options...
SamPo Posted August 31, 2021 Author Report Share Posted August 31, 2021 Thank you, that has worked! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.