Jump to content
  • 0

Calendar - Make Start Date 2 Days After Current (Today's) Date


AnitaBhakta

Question

7 answers to this question

Recommended Posts

  • 0
Hello themonitor,
 
Welcome to forum!
 
On your Submission Form, you can add a Header & Footer element. Then you can select the Footer element, click the "Source" button and enter the following code:
<SCRIPT LANGUAGE="JavaScript">

function check_date()
{
var entered_value = document.getElementById("InsertRecordFIELDNAME").value;
var entered_date = new Date(entered_value);

var tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);

if(entered_date < tomorrow)
   {
      alert("Please select a date after tomorrow");
      return false;
   }
}

document.getElementById("caspioform").onsubmit=check_date;
</SCRIPT>

Please enter name of your field instead of "FIELDNAME" in the line

var entered_value = document.getElementById("InsertRecordFIELDNAME").value;
 
Also you can enter your message instead of "Please select a date after tomorrow".
 
I hope, it helps.
Link to comment
Share on other sites

  • 0

i tried copying the var statements 2 more times and changing the field name to start_date2 and then start_date3

and then adding an else if and else statement, but the pop-up kept on going, as if it was ignoring the other rule.

 

then i tried doing this:

 

var entered_value = document.getElementById("InsertRecordstart_date","InsertRecordstart_date2","InsertRecordstart_date3").value;

 

 

BUT that didn't seem to work at all just ignored start_date2 and start_date3 all together as if the code wasn't in there.

I"m new to javascript.. watched some videos online and thought it would work.

Link to comment
Share on other sites

  • 0

Hello themonitor,

 

I think, you can use the following code:

 

<SCRIPT LANGUAGE="JavaScript">
function check_date()
{
var entered_value = document.getElementById("InsertRecordfirst").value;
var entered_date = new Date(entered_value);
var tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);

if(entered_date < tomorrow)
   {
      alert("Please select a date after tomorrow");
      return false;
   }

var entered_value2 = document.getElementById("InsertRecordsecond").value;
if (entered_value2 !="")
{
var entered_date2 = new Date(entered_value2);
if(entered_date2 < tomorrow)
   {
      alert("Please select a date2 after tomorrow");
      return false;
   }
}

var entered_value3 = document.getElementById("InsertRecordthird").value;
if (entered_value3 !="")
{
var entered_date3 = new Date(entered_value3);
if(entered_date3 < tomorrow)
   {
      alert("Please select a date3 after tomorrow");
      return false;
   }
}
}

document.getElementById("caspioform").onsubmit=check_date;
</SCRIPT>

Please insert your fieldnames instead of first, second, third.

 

I hope, it helps.

Link to comment
Share on other sites

  • 0

i'm trying to use the same code on a update form i also don't want them to be able to fill out the form initially then update and change the dates to something differnt in the update form. I would like to have the same rules as stated above on the update form

i tried changing the script to instead of InsertRecord i tried changing it to @field:

but that didn't work.. can you help again...

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.

Guest
Answer this question...

×   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.

Loading...
×
×
  • Create New...