Jump to content

Javascript alerts showing multiple times


Recommended Posts

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>

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...