These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Check Time from Start time and End Time

ajep
Registered: Oct 24 2011
Posts: 15
Answered

I have two time boxes one is the Start time and the second is the End time of the event. I want to write a check that will not let the user submit the form if the times are incorrect. Start time has to come always before End time. I did this with dates but i dont know if it works with time only. I dont mind either Javascript or FormCalc help on this. thanks
 
Form.#subform[0].Button1::preSubmit:form - (Javascript, client)
 
var time1Num = Time2Num(starttime.rawValue,"HH-MM-SS")
var time2Num = Time2Num(endtime.rawValue,"HH-MM-SS")
if (time2Num < time1Num) then
xfa.host.messageBox("The End time must be after the Start time.","Input Error", 0, 0);
datecheck.mandatory = "error"
else
datecheck.mandatory = "disabled"
endif

My Product Information:
LiveCycle Designer, Windows
ajep
Registered: Oct 24 2011
Posts: 15
Accepted Answer
if (starttime ne null and endtime ne null) then
//if start time is lower than end time.
if (Time2Num(starttime.formattedValue, "HH:MM") < Time2Num(endtime.formattedValue, "HH:MM")) then
//xfa.host.messageBox("start time is lower than end time.","Input Error", 0, 0);
datecheck.mandatory = "disabled"
else
//If start time is higher than end time we passed the date line
xfa.host.messageBox("start time is higher than end time .","Input Error", 0, 0);
datecheck.mandatory = "error"
endif
endif

got it and in my time control i have time{HH:MM:} for Display,Edit,Validate,Data