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

dd/mm/yyyy ?

tgmoon
Registered: Jul 5 2007
Posts: 6

can anyone help.

I adapt the following code to show dd/mm/yyyy instead of the dd/mm/yy it doing at the moment.

function checkValidDate(oField)
{
var sValue = oField.formattedValue; //rawValue format is YYYY-MM-DD, so formattedValue must be used.

if (sValue == null || sValue == "")
return true;

//Create a new Regular Expression Object
var regExp = new RegExp();
var sExp = /^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/(\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/(\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/(\d{2}))|(29\/02\/((0[48]|[2468][048]|[13579][26])|(00))))$/;
regExp.compile(sExp);

if (!regExp.test(sValue))
{
xfa.host.messageBox("Please enter a valid date in the format 'DD/MM/YY'.", "Invalid date");
xfa.host.setFocus(oField.somExpression);
return false;
}

return true;
}

Many thanks

Thom

Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi tgmoon,

It seems like you are doing this the hard way since the pattern dd/mm/yyyy is available without having to use a regular expression. But maybe I am missing something key about the methodology you are using.

Check out this forum thread at Adobe.com, and download the example form Stefan (FormBuilder) provided in the 5th message in the thread.

If that is not helpful, then please repost and provide more info.

Hope this helps,

Dimitri
WindJack Solutions
www.windjack.com