Hi folks,
Back after long time to the forums, where I get answers which are helpful in making me good at utilizing designer.
I am trying to validate the "Date/Time Field" using JavaScript but couldn't get a proper RegEx expression for various invalid user input formats. If anyone can help me out in finding a proper script that would Great.
My script grown bigger and bigger to accepting invalid dates, but felt like hardcoding. So, instead I decided why can't we prevent a user to enter data into "Date/Time Field" and use only calendar dropdown. Is there is a way to do this?
find my sample testing docment
https://acrobat.com/#d=mYXkrhO2txuEesCfmvxNXg
Thanks in Advance,
Rajesh
Views
Replies
Total Likes
Hi Rajesh,
I don't think there is a way of stopping the user from using the keyboard to enter a date. You can use the following script in the change event to stop them typing a date but they will still be able to paste a date in.
if (xfa.event.change.length === 1)
{
xfa.event.change = "";
}
This code works because if the date is selected from the calendar dropdown then the date xfa.event.change value will be the whole date and therefore longer than one character.
I couldn't access your sample but if you were to set an display picture for the date field to something other than date{YYYY-MM-DD} then a valid date will have a formattedValue that is different than the rawValue.
Dave
Hi All,
Please note this worn't work in XFA 3.3 (Reader 10.1) as there is a bug that restricts the change event from being overwritten. http://forums.adobe.com/message/3956926#3956926
Kind Regards
Kev
Solutions Architect
Avoka
Thank You Dave and Kavin,
Dave, find the working copy https://acrobat.com/#d=Gcr*icvepRfzXAqEHYwL5A
hmm, that is bad, to hear, Kavin, a bug. so there is any by pass that we can make the above scripting work in Reader 10.1?
Please let me know.
Once again thanks,
Rajesh
Views
Replies
Total Likes
Hi Rajesh
It will work in Reader 10.1 if the compatibility is set to anything else than "Reader 10 and above" as this will use a different rendering agent. The bug only exists in XF3.3
Sorry for any confusion.
Kind Regards
Kev
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies