Answered
Looks like I'm digging a hole for myself. (Valantine is over.) I need to create a form!
The "user" wants to type the date and the time without spaces: 15022010 resulting in 15-02-2010.
Acrobat converts 15/02/2010 and 15:02:2010 by it self to the requested 15-02-2010 just by selecting the formating notation. So this without the spaces is an extra wish!
I don't want to loose the features where: / feb ; is converted dd-mm-yyyy
In the form there is asked for a lot of other numbers.
Here is the script I use now:
date_val("1.5"); ///---------------------- function current_date( f ) { var x = getField ( f ); var cDate = util.printd("dd-mm-yyyy", new Date()); if (x.value == "") { x.value = cDate; } } ///----------------------- function date_val ( f ) { var x = getField( f ); var d1 = util.scand("dd/mm/yyyy", x.value); var d2 = new Date(); var givenyear = d1.getFullYear(); var thisyear = d2.getFullYear(); var diff = givenyear - thisyear; if (diff > 10) { app.alert("\nCheck the date.",2,0); getField(f).setFocus(); return false; } // ------------------------- else if (( (d2.valueOf() - d1.valueOf()) / 1000 ) < -86399 ){ app.alert ("\nThe date of travel in the future is invalid.",2,0) getField(f).setFocus(); return false; } // ------------------------- if (( (d2.valueOf() - d1.valueOf()) / 1000 ) >= 7776000 ){ app.alert ("\nThe date of your request has expired.",2,0) getField(f).setFocus(); return false; } return true; }
If you want some special formatting for the field you'll need to write you're own custom format script.
Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]
The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]
Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script