I've been scouring the 'net (and these boards) for days now. [img]http://www.theamazingcams.com/animated_icons/book.gif[/img] I cannot, for the life of me, figure out this problem. Anyone who can help - I'd appreciate it!
Here's the scenario:
I have a button, which is called "Setdate". It uses JS to fill in the current date to the field "Today" (and this works correctly.)
this.getField("Today").value = util.printd("mm/dd/yyyy", new Date());
I then have two date fields, called "Spec1OLD" and "Spec2OLD", respectively. I need to compare the date the user enters in those fields, against the current date (in the field "Today"), and if the date the user enters is LESS than today's date, have Acrobat throw an error dialog; if it's equal to or greater, move to the next field (called "Spec1OLDstartTime" or "Spec2OLDstartTime".) I also only want the code validation to happen if both fields have a value (if the Today field is blank, the validation should not happen.)
This is the code I am using for the respective fields:
Spec1OLD / Spec2OLD (names are changed in my PDF, but the code is the same)
var strA = util.scand("mm/dd/yyyy", this.getField("Today").value); var strB = util.scand("mm/dd/yyyy", this.getField("Spec1OLD").value); if (strB.length || strA.length) if (strB > strA) app.alert({cMsg:"day\/date cannot be less than today\'s date. Please choose a date at least 48 hours from today\'s date.",nIcon:1}); else{ if (strB <= strA) if ( event.fieldFull || event.willCommit ) this.getField("Spec1OLDstartTime").setFocus(); }
Unfortunately, I cannot, for the life of me, get this to work. [img]http://tampabaymiatas.net/forum/images/smiles/eusa_wall.gif[/img]
Can anyone provide any insight as to what I'm doing wrong?
var strA = util.scand("mm/dd/yyyy", this.getField("Today").value);
var strB = util.scand("mm/dd/yyyy", this.getField("Spec1OLD").value);
// some added debugging code for information
console.show()
console.println("Today:")
console.println("entry: " + strA);
console.println("length: " + strA.length);
console.println("vlaue: " + strA.valueOf() );
console.println("date:")
console.println("entry: " + strB);
console.println("length: " + strB.length);
console.println("vlaue: " + strB.valueOf() );
console.println("B > A: " + ( strB.valueOf() > strA.valueOf() ) );
// end debugging code
if ( strB.valueOf() < strA.valueOf() )
app.alert({cMsg:"day\/date cannot be less than today\'s date. Please choose a date at least 48 hours from today\'s date.",nIcon:1});
else{
if (strB.valueOf() <= strA.valueOf())
// if ( event.fieldFull || event.willCommit )
this.getField("Spec1OLDstartTime").setFocus();
}
George Kaiser