Copy link to clipboard
Copied
Thanks in advance for your help. I have date fields in an Acrobat form. Is it possible to create a script to format a date as either MM/DD/YYYY or MM/DD/YY? In other words, if someone enters MM/DD/YYYY, the date would be accepted and MM/DD/YY would also be accepted. Thanks, again.
Copy link to clipboard
Copied
I think an error dialog is better than an unclear value. Millions (if not
more) of dollars and thousands (if not more) of man hours were spent on
solving the Y2K bug. Don't fall in the same trap...
Copy link to clipboard
Copied
You can write your own custom validation script to allow that, but I would
recommend against it.
Copy link to clipboard
Copied
Thanks for your response. There is really no other way to control the format of the date? I would just like the date field to accept either mm/dd/yyyy or mm/dd/yy. (It would be great if the date could automatically be converted to mm/dd/yyyy, but if I enter anything other than mm/dd/yyyy, a dialog box appears indicating that the data was not in correct format.) Thanks, again!
Copy link to clipboard
Copied
How would you make that conversion? Let's say the user enters "12/10/50".
Is that 2050 or 1950?
Copy link to clipboard
Copied
Good point. To be honest, it could be either. The dates entered are generally birthdates and signature dates. The birthdates could be 19XX or 20XX. The signature dates would be 20XX. I'm just trying to avoid an error dialog when the user enters a date as mm/dd/yy or m/d/yy. Thanks for your insight and help.
Copy link to clipboard
Copied
I think an error dialog is better than an unclear value. Millions (if not
more) of dollars and thousands (if not more) of man hours were spent on
solving the Y2K bug. Don't fall in the same trap...
Copy link to clipboard
Copied
You are right! Thanks for your help.
Copy link to clipboard
Copied
Most life insurance companies figured out the solution in the early 1970's when their annuitants who were born in the 1870's had a birthday.
The use of the 2 digit year was based on the cost of storage and the lack of input space on Hollerith cards (IBM punch cards). All issues that have now been resolved.
With the shrinking globe and cheap storage, use of the day-month-full year, d-mmm-yyyy, more clearly identifies the date than ##/##/## which could be any combination or month day and year.
This is not rocket science or is it?
Copy link to clipboard
Copied
This is not rocket science or is it?
No, it's not... Did I say it was?
Copy link to clipboard
Copied
Might need a DuPont Engineer towork it out though.
Copy link to clipboard
Copied
Since the time measurement is based on a sattilite revolving around another object in space, much of the concepts and measurements apply to rocket science. But I do not know if all rocket scientist woudl get it. Wasn't there a sattilite that mixed miles and kilometers within the navigation program with a suprising result.
One needs to get to a common unit and then just do the math.
Actually JavaScript does have an adjustment for the Date.getYear if the date object is established with the 4 digit year.
I had a recent issue at work. I work from the U.S and have to access data on a server in the UK using Remote Desktop and the remote deskto is configured for the UK date format unless the user changes it. In prior years the data was processed on servers in the U.S. with U.S. date format. There were many instances when the date and month were swithed and requires over a month to fix. Thank you Microsoft Certified Network Administrators.
 
      Copy link to clipboard
Copied
To avoid possible confusion due to inconsistent user inputs, have you thought of having 3 combo boxes, one each for day, month and year?
Combo boxes are a good way to force the user to pick a specific response.
The user's choices from the combo boxes can then be imported into a text field on your form.
Copy link to clipboard
Copied
I would recommend against that, as that involves a lot of scripting changing the days drop-down according to the selected month and year.
Just use a text field with a pre-defined date format. That will take care of all of these issues for you.
Copy link to clipboard
Copied
Under text field's property > option, you can limit amount of character in the text field.
Then, under validation, choose "Run custom validation script" with the following script:
//Force the text field only accept numeric value//
var alphaNumericPatt = /^[0-9]*$/;
event.rc = alphaNumericPatt.test(event.value);
//Break the string into three group of numbers//
var dobD = event.value.substring(0,2)
var dobM = event.value.substring(2,4)
var dobY = event.value.substring(4,8)
// Combine the string with "/" as divider to the format like this DD/MM/YYYY //
var dobFull = dobD + "/" + dobM + "/" + dobY
event.value = dobFull
Copy link to clipboard
Copied
When entering date in dd/mm/yyyy format into received Adobe PDF forms, I always got a JavaSript error telling that date format should be m/d/y. JavaSript then automatically reverts my entered date to this format ! And this with any Internet browser, even with default languages set to English UK or French and Windows 7 date set to European format.
I found many complaints and questions on this subject on the WEB, but except some very technical Java programming suggestions, I found no solutions.
But finally, playing with one of PDF forms, I FOUND A SIMPLE SOLUTION !
Cheers !
Copy link to clipboard
Copied
But will it be a valid date and will it be the date the user wanted entered?
Also you will be eliminating a lot of other JavaScript actions that maybe needed by the form. An example would be the computing of the age based on the date of birth entered.
One can use the RegExp option for the custom keystroke, custom format, and custom validation to get this to work, but one still needs to deal with the issue of dates that could be spanning more than 100 years.
Copy link to clipboard
Copied
Well, this was concerning of entering a birth date into the received form.
And after disabling JavaScript, I could enter date in any wanted form and it was kept as it is when printing or sending the response via email. There was no other modification done by disabling JavaScript. So, it did work!
Maybe for particular applications like calculating the age from entered date it won't work, but then it would require programming knowledge that average user having to fill-in the form doesn't have, nor needs for such a simple usage.
Copy link to clipboard
Copied
It worked on your end, sure, but when you submit it back to them and they try to export the data and import it into their database, for example, it will fail and your form will be rejected.
Copy link to clipboard
Copied
Maybe for particular applications like calculating the age from entered date it won't work, but then it would require programming knowledge that average user having to fill-in the form doesn't have, nor needs for such a simple usage. 
It is up to the form author to add the script necessary to have the form perform calculations and other automated tasks not the person entering the form data. In fact, since most of the users filling in the form will be using Adobe Reader or other application, they will not have the ability to access the JavaScripts or use the JavaScript editor.
 
					
				
				
			
		
 
					
				
				
			
		
Find more inspiration, events, and resources on the new Adobe Community
Explore Now