Assuming the input date field is named "Date" and the 3 output fields are "Day", "Month", and "Year", the following validation script for the "Date" field will populate the 3 output fields.
// document level function;
function ordinal(i) {
/*
purpose: convert inter to ordinal number;
input: any integer;
return: intieger and ordinal suffix;
*/
var cOrdinal = "";
var sufixes = new Array("th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th");
switch (i % 100) {
case 11:
case 12:
case 13:
cOrdinal = i + "th";
break;
default:
cOrdinal = i + sufixes[i % 10];
break;
} // end switch;
return cOrdinal;
} // end of ordinal function;
// end document level function
// custom validation script;
// can include above document level function;
var cDate = "";
var cMonth = "";
var cYear = "";
if(event.value != "") {
cFormat = "mm/dd/yy"; // must be the same format as the field being validated;
var oDate = util.scand(cFormat, event.value); // convert to date objec;
// validate input date;
if(oDate == null)
{
app.alert("Input date is not a valid date", 1, 0, "Entry Error");
} else {
// date as ordinal number;
var cDate = ordinal(oDate.getDate());
// spelled out month;
var cMonth = util.printd("mmmm", oDate);
// two digit year;
var cYear = util.printd("yy", oDate);
} // end date validation;
} // end target value not null;
// set field values;
this.getField("Day").value = cDate;
this.getField("Month").value = cMonth;
this.getField("Year").value = cYear;
// end validation script;
The above code will also validate the inputted date and clear the output fields if the input field is blank.