Harpreet Posted January 13 Report Share Posted January 13 Hello , I am using a javascript that should restrict me from submitting form based on condition. I have field Start date and field End Date. Then I am using a virtual calculated field to find number of days from the above two fields. Now if my value is greater than 5 it should restrict me to submit the form <script> document.addEventListener('BeforeFormSubmit', function(event) { let checkValue = document.getElementById("cbParamVirtual3").value; if (checkValue > 5) { event.preventDefault(); alert("You are not authorized to create this account."); } }); </script> Ca anybody please help Quote Link to comment Share on other sites More sharing options...
autonumber Posted January 13 Report Share Posted January 13 Hello @Harpreet- you can check these forum posts for prevent submission. Quote Link to comment Share on other sites More sharing options...
Harpreet Posted January 16 Author Report Share Posted January 16 Fantastic... Thanks @autonumber Quote Link to comment Share on other sites More sharing options...
PotatoMato Posted February 23 Report Share Posted February 23 Hi @Harpreet! Just to add, your condition is already correct, but there is a mistake in the declaration on your field. You may use this instead: let checkValue = document.getElementsByName("cbParamVirtual3")[0].value; -Potato 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.