Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript Time validation in PDF form

gavin1f4

New Coder
Hi,

I have a PDF form that has 4 times on it, OUT, OFF, ON, IN. These times are in order and always have a time greater than the last. I am trying to right a script that will validate these times so that times in the past cannot be in the past. OFF should be greater than OUT, On should be greater than OFF, and IN should be greater to ON. Also what happens when the times cross midnight I am not sure how to validate that. If an OFF time is 23:30 and an ON time is 01:00 value wise 01:00 is less than 23:30 but time wise it is greater since it is a new day.

Thanks
 
You don't say how you get the four times. I would get the day month and year also so you can account for times during the year change over [Dec 31 to Jan 1]
Use const date = new Date(2016, 11, 17, 0, 0, 0, 0) remembering the months start at 0 and run to 11. See JavaScript Date Objects
Then let time = date.getTime(); This object will let you compare the numbers and get the lowest one.
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom