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

Time validation with JS

paga
Registered: Sep 9 2009
Posts: 3
Answered

Hi, I have a script in my PDF form to calculate time

here's my script:
event.value = (this.getField("end_monday").currentValueIndices - this.getField("start_monday").currentValueIndices) / 4 ;

So far, it works good... but, I want to be able to substract 30 min from that total if a certain check box is checked...

Can anyone help me with this ?
Thanks in advance

Paga

My Product Information:
Acrobat Pro 9.0, Macintosh
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
Most users work with time strings and the JavaScirpt date object and compute the interval and then display the result in hours and minutes.

It appears you are computing the time in 15 minute intervals from a series of the value indices from a pair of drop down boxes and displaying the time as decimal hours.

You can check the value of the check box to be 'Off' for the non-selected state of the box, the export value for the selected state of the box, or use the 'isBoxChecked()' method to see test for the box being checked without knowing the value for that box.

event.value = (this.getField("end_monday").currentValueIndices - this.getField("start_monday").currentValueIndices) / 4 ;// check the '0' widget of the 'monday_lunch' check box fieldif (this.getField('monday_lunch').isBoxChecked(0) ) {// subtract 0.5 hoursevent.value = event.value - 0.5;}

I would do this as a calculation script for the result field and not a validation script.

George Kaiser

paga
Registered: Sep 9 2009
Posts: 3
Thanks a lot for the quick help
works like a charm...

Paga