Jump to content
SunLover

Timing modifications to a datapage

Recommended Posts

I am creating a datapage where my clients can make request for the time and date of a specific inspection. In order to be able to coordinate the inspectors I have to limit the time that the requests are made, therefore I need to create a condition that does the following:

to process the request online then the request has to be made at the latest the prior business day before by 5:00 pm (local time)

For example today is Tuesday at 6:00 pm local time, therefore the earliest inspection available is for Thursday since is already after 5:00 pm to request for tomorrow.

I am intermediate user that have created a significant application but I don't have programming knowledge, so any help is really appreciated.

 

Share this post


Link to post
Share on other sites

Try this code on the Footer of the page. Make sure to disable HTML editor



<script>

document.getElementById('Submit').onmouseover = function (){
var d = new Date()

var dd = d.getDate()+1;
var mm = d.getMonth()+1;//January is 0!
var yyyy = d.getFullYear(); 

if(dd<10){dd='0'+dd}
if(mm<10){mm='0'+mm}

var tomorow = mm+'/'+dd+'/'+yyyy;
var time = d.getHours(); 
var min = d.getMinutes();

var date=document.getElementById('InsertRecorddate').value;
var myDate = new Date(Date.parse(date));


if(myDate.getDay() == 6 || myDate.getDay() == 0) 
{

alert('Weekend! You need to pick week days date');
return false;
}
else if (date == tomorow && time >= 15)
{
alert("Too late to schedule for tomorrow");
return false;
}
}
</script>

Replace InserRecorddate with field ID user inputs requested inspection date. Also since I wanted to check the code I have to reject requests after 3 PM

"else if (date == tomorow && time >= 15)" for your case :)

Change it to "else if (date == tomorow && time >= 17)"

Share this post


Link to post
Share on other sites

Hi MayMusic, thanks for taking the time to help me.

I hadn't been able to work on this since I posted the question. I did tried tonight though and it doesn't seem to work. I am not sure I am doing something wrong :-(

this is what i have in the footer and I disabled html editor. Do you think you can take a look for me again? thanks a lot!

<script>

document.getElementById('Submit').onmouseover = function (){
var d = new Date()

var dd = d.getDate()+1;
var mm = d.getMonth()+1;//January is 0!
var yyyy = d.getFullYear(); 

if(dd<10){dd='0'+dd}
if(mm<10){mm='0'+mm}

var tomorow = mm+'/'+dd+'/'+yyyy;
var time = d.getHours(); 
var min = d.getMinutes();

var date=document.getElementById('Date_of_Inspection').value;
var myDate = new Date(Date.parse(date));


if(myDate.getDay() == 6 || myDate.getDay() == 0) 
{

alert('Weekend! You need to pick week days date');
return false;
}
else if (date == tomorow && time >= 17)
{
alert("Too late to schedule for tomorrow");
return false;
}
}
</script>

Share this post


Link to post
Share on other sites

The ID you are having in this line:

var date=document.getElementById('Date_of_Inspection').value;

Does not seem to be right, if the field name is " Date_of_Inspection " and you are in a submission page the ID should be "InsertRecordDate_of_Inspection", on update page it should be "EditRecordDate_of_Inspection". Refer to

Replace the ID and that should help

Share this post


Link to post
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
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.

Loading...

×
×
  • Create New...