telly Posted July 20, 2019 Report Share Posted July 20, 2019 Hi - I want to stop form submission if certain criteria is not met, is this possible? Quote Link to comment Share on other sites More sharing options...
SunakoChan Posted July 20, 2019 Report Share Posted July 20, 2019 Hi Telly, You can try this: <script type="text/javascript"> document.addEventListener('BeforeFormSubmit', function(event) { if (condtion) { //result if condition is met } else { event.preventDefault() } }); </script> Also, check this helpful link: https://howto.caspio.com/datapages/ajax-loading/ JckDY 1 Quote Link to comment Share on other sites More sharing options...
JolliBeng Posted July 21, 2019 Report Share Posted July 21, 2019 Hi @telly, The solution that @SunakoChan provided is correct. You'll need JavaScript coding to prevent submission. For more details, you may also check this forum post: -JolliBeng JckDY 1 Quote Link to comment Share on other sites More sharing options...
cheonsa Posted June 18, 2020 Report Share Posted June 18, 2020 Hi @telly, You can use this code to prevent a submission form if a certain condition is not met. <script type="text/javascript"> document.addEventListener('BeforeFormSubmit', function () { event.preventDefault(); var a = document.getElementById("InsertRecordFIELDNAME").value; if (a > 100) { alert('Please enter number less than 100.'); } else { document.forms["caspioform"].submit(); } }); </script> Cheers! RickManolo 1 Quote Link to comment Share on other sites More sharing options...
DanielL Posted July 9, 2020 Report Share Posted July 9, 2020 Slight modification to get this to work - it appears that the ID now has a number appended to it (e.g., InsertRecordFIELDNAME_7647422799) . You can use the document.getElementsByName to find the first name in the array. <script type="text/javascript"> document.addEventListener('BeforeFormSubmit', function () { event.preventDefault(); var a = document.getElementsByName("InsertRecordFIELDNAME"); if (a[0].value > 100) { alert('Please enter number less than 100.'); } else { document.forms["caspioform"].submit(); } }); </script> Quote Link to comment Share on other sites More sharing options...
followersuk Posted July 11, 2020 Report Share Posted July 11, 2020 The submit event triggers when the form is submitted, it is usually used to validate the form before sending it to the server or to abort the ... Quote Link to comment Share on other sites More sharing options...
AtayBalunbalunan Posted July 12, 2020 Report Share Posted July 12, 2020 You can also get the unique ID for the DOM element using event.detail.uniqueSuffix. An example can be seen in https://howto.caspio.com/datapages/ajax-loading/. 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.