In search of JavaScript to format date field in browser
It is a known issue that the date picker does not work in web browsers. I accept that. I have seen the other posts, including:
How do you make Date Drop downs available to use o... - Adobe Support Community - 12758876
Calendar in date field is not working in Chrome - Adobe Support Community - 13173706
If I just enter numbers into the date field in a browser, such as “05152023”, it converts it to current date (“08/14/2023”). If I enter “02122023”, it converts to “02/22/2023” (yes, it changed the day value). If I enter a formatted date, such as “05/15/2023”, it’s ok.
So, my question – is there a way to use JavaScript to intercept the date and add formatting, before it gets changed by the browser?
Please note, I am already using the following to convert the datepicker to mm/dd/yyyy, as the default date format in our system is d.m.yyyy (which is probably another reason the date is getting messed up, but I can’t fix that):
var DateOfSignature = this.getField("DocumentSignature_DateOfSignature");
var requiredFormat = "mm/dd/yyyy";
DateOfSignature.setAction("Format", "AFDate_FormatEx(\""+requiredFormat+"\")");
DateOfSignature.setAction("Keystroke", "AFDate_KeystrokeEx(\""+requiredFormat+"\")");
I think I need a way to tell if I am using Adobe or a web browser to prevent the code above from firing, but I have not found a way to do that yet, either. Please note, the PDF is being created in Inspire Designer, so that adds its own layer of complexity to the situation.
Thanks.
