Jump to content

Comparing dates in submission form

Recommended Posts

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:

  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");

How can I fix this issue? 

Thanks in advance. 

Link to comment
Share on other sites

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:

  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;


Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...