rrushton Posted April 12, 2019 Report Share Posted April 12, 2019 I am creating a sales form which produces an error if there is not enough available quantity. I am using virtual fields and the below script is successful. The script below produces the error when Virtual 8 is > either Virtual 7 OR Virtual 3. I need to add to it to produce the error when Virtual 8 is greater than Virtual3 OR Virtual7 OR Virtual11 OR Virtual14. NOTE: Virtual3 will always have a value, while only one of Virtual 7, 11 or 14 will ever have a value. <script> document.addEventListener('BeforeFormSubmit', function(ev) { var virtual3 = +document.querySelector(`[action*="[@cbAppKey]"] [id*=cbParamVirtual3]`).innerText; var virtual7 = +document.querySelector(`[action*="[@cbAppKey]"] [id*=cbParamVirtual7]`).innerText; var virtual8 = +document.querySelector(`[action*="[@cbAppKey]"] [id*=cbParamVirtual8]`).innerText; if (virtual8 > virtual3 || virtual8 > virtual7 ) { ev.preventDefault(); alert("Error: Not enough spaces! Please chose a tour with more availability"); } }) </script> Would anyone be able to help with this script? Quote Link to comment Share on other sites More sharing options...
George43 Posted April 12, 2019 Report Share Posted April 12, 2019 Please try this code. If you have any problems please provide export of your app without sensative data in order to customize more deeply. <script> document.addEventListener('BeforeFormSubmit', function(ev) { var virtual3 = +document.querySelector(`[action*="[@cbAppKey]"] [id*=cbParamVirtual3]`).innerText; var virtual7 = +document.querySelector(`[action*="[@cbAppKey]"] [id*=cbParamVirtual7]`).innerText; var virtual8 = +document.querySelector(`[action*="[@cbAppKey]"] [id*=cbParamVirtual8]`).innerText; var virtual11 = +document.querySelector(`[action*="[@cbAppKey]"] [id*=cbParamVirtual11]`).innerText; var virtual14 = +document.querySelector(`[action*="[@cbAppKey]"] [id*=cbParamVirtual14]`).innerText; if (virtual8 > virtual3 || virtual8 > virtual7 || virtual8 > virtual11 || virtual8> virtual14) { ev.preventDefault(); alert("Error: Not enough spaces! Please chose a tour with more availability"); } }) </script> 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.