telly 1 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 post Share on other sites
SunakoChan 15 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 post Share on other sites
JolliBeng 28 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 post Share on other sites
LittleMsGinger 26 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 post Share on other sites
DanielL 0 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 post Share on other sites
followersuk 0 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 post Share on other sites
AtayBalunbalunan 43 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 post Share on other sites
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.