SunLover Posted June 21, 2016 Report Share Posted June 21, 2016 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. Quote Link to comment Share on other sites More sharing options...
MayMusic Posted June 21, 2016 Report Share Posted June 21, 2016 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)" Quote Link to comment Share on other sites More sharing options...
MayMusic Posted June 21, 2016 Report Share Posted June 21, 2016 Also please note it gets the user system time and date. Quote Link to comment Share on other sites More sharing options...
MayMusic Posted June 22, 2016 Report Share Posted June 22, 2016 @SunLover did it help? Quote Link to comment Share on other sites More sharing options...
SunLover Posted July 1, 2016 Author Report Share Posted July 1, 2016 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> Quote Link to comment Share on other sites More sharing options...
MayMusic Posted July 1, 2016 Report Share Posted July 1, 2016 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 Quote Link to comment Share on other sites More sharing options...
SunLover Posted July 4, 2016 Author Report Share Posted July 4, 2016 Thank you MayMusic, I will try to make it work 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.