Sander Posted August 18, 2016 Report Share Posted August 18, 2016 The thing I'm trying to achieve is that users of my app can only plan a date after today, with "rules" I am able to display a message when a user selects a date before today with the date picker. I achieve this by hiding a section when the given date is ok (Input_date > Timestamp). But while it is not possible to prevent users from submitting the form when a condition is not met, I'm trying to find a solution in javascript. The problem that occurs is that the format differs, the inputfield of the user is DD-MM-YYYY and the timestamp i compare it with is MM/DD/YYYY. Strangely this is not a problem with "rules". The code I use: <script> function myFunction(){ var StartDate = document.getElementById("InsertRecordStartDate").value; var Today = document.getElementById("cbParamVirtual1").value; // This virtual field receives the timestamp onload if (StartDate < Today){ alert('Not all conditions are met"); event.preventDefault(); } document.getElementById("caspioform").onsubmit=myFunction; </script> How can I fix this issue? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Mathilda Posted August 18, 2016 Report Share Posted August 18, 2016 Hi Sander, In the virtual field on load receive external parameter [@cbTimestamp*]. In this case time will be excluded. Also edit Localization and make date input mask like DD/MM/YYYY. You can find this setting in "Formatting Standards" I've edited your script: <SCRIPT LANGUAGE="JavaScript"> function myfunction(){ var StartDate = document.getElementById("InsertRecordStartDate").value; var Today = document.getElementById("cbParamVirtual1").value; if (StartDate<Today||StartDate==Today) { alert('Not all conditions are met'); return false; } } document.getElementById("caspioform").onsubmit=myfunction; </SCRIPT> Quote Link to comment Share on other sites More sharing options...
Sander Posted August 18, 2016 Author Report Share Posted August 18, 2016 Thank you mathilda! Without the time and the correct format it is comparing the way I want. One problem less to worry about. 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.