Javascript: DateFormField.setDateFormat Method
Description
Sets the date's format. For a certain DateFormField the format string should be one of the strings returned through the getSupportedDateFormats function. A TextControl uses Day, Month, Year, and Era Format Picture strings to format a date. When this date's format is an empty string, which is the default value, a default format is used depending on the culture set for the date field's text.
Syntax
<void> DateFormField.setDateFormat(<String> dateFormat, [<EmptyRequestCallback> callback], [<ErrorCallback> errorCallback])Parameters
| Parameter | Description |
|---|---|
| dateFormat | Specifies the date's format. |
| callback | Optional. Is called when the operation completed. |
| errorCallback | Optional. Is called when the operation failed with an error. |
Examples
The following example demonstrates DateFormField.setDateFormat in a practical document-editing workflow. It sets the date's format. For a certain DateFormField the format string should be one of the strings returned through the getSupportedDateFormats function. A TextControl uses Day, Month, Year, and Era Format Picture strings to format a date. When this date's format is an empty string, which is the default value, a default format is used depending on the culture set for the date field's text.
function onTxError(error) {
console.error("TX Text Control error:", error.msg);
error.handled = true;
}
function configureDateFormat(dateFormField) {
dateFormField.setDateFormat(
"MM/dd/yyyy",
function() {
console.log("set date format completed.");
},
onTxError
);
}