These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Forcing Date Formats - How Do I Manage this

zk6760
Registered: Dec 23 2009
Posts: 6

Hi All,

Ive tried searching but havent come up with anything to really solve my issue, and I believe it shouldnt be hard, but I cant seem to figure out a solution.

At the moment I have a text field and simply want the users to enter the date as yyyy-mm-dd. If they dont, I want it to clear the field and reset focus there until they do.

I've tried using a date field and setting validation patterns, but all it does it give an error message and lets the user move on.

Is there anyway to force this? (I dont have the new Adobe version ES2, so there are not validation options under Form Properties).

Thank you all in advance!

Z

zk6760
Registered: Dec 23 2009
Posts: 6
Does anyone know if this can be done using RegExp?

For example:

if(Page1.Variable.rawValue != [0-9]{4}-[0-9]{2}-[0-9]{2}) xfa.host.messageBox("Incorrect Format");

I have the above now, but it is not working. I am very confused. 8 hour workday and nothing accomplished.

Help PLEASE!
zk6760
Registered: Dec 23 2009
Posts: 6
Well I guess I dont need anyones help b/c I found my solution...

I'm posting it in case anyone else was just as dumbfounded as me (I never even heard of RegEx until today and just began reading up on it)

var re = /([0-9]{4})-([0-9]{2})-([0-9]{2})/;

if(!Page1.P1TDate.rawValue.match(re)){
xfa.host.messageBox("Incorrect format. Please re-format to match YYYY-MM-DD.");
this.rawValue = "";
xfa.host.setFocus(this.somExpression);
}

*and yes you could sub in \d for each [0-9]