TX Text Control .NET Server

DateFormField Object

Object|Introduced in 28.0

Description

A DateFormField object represents a date field on a form. It can be initially empty and it can have a horizontal extension, when it is empty. When a date field is clicked or entered through the keyboard's arrow keys a date control is shown where the user can select a date. When the date field is clicked again or the Escape key is pressed the date control is removed and the user can insert or change the date with the keyboard. The date is formatted depending on the culture used for the text of the date field. When a date field is inserted at a position without a set culture, a TextControl uses the system language to select a culture. Supported formats for a certain language can be obtained through the DateFormField.getSupportedDateFormats method and can be set with the DateFormField.setDateFormat method. When the DateFormat is an empty string, which is the default, the culture's default format is used. A user can also insert or change a date with the keyboard, then the TextControl tries to parse the inserted date depending on the specified format and culture and automatically formats the date. When parsing is not possible the previous date is restored.

Syntax

DateFormField

Examples

The following example demonstrates DateFormField in a practical document-editing workflow. A DateFormField object represents a date field on a form. It can be initially empty and it can have a horizontal extension, when it is empty. When a date field is clicked or entered through the keyboard's arrow keys a date control is shown where the user can select a date. When the date field is clicked again or the Escape key is pressed the date control is removed and the user can insert or change the date with the keyboard. The date is formatted depending on the culture used for the text of the date field. When a date field is inserted at a position without a set culture, a TextControl uses the system language to select a culture. Supported formats for a certain language can be obtained through the DateFormField.getSupportedDateFormats method and can be set with the DateFormField.setDateFormat method. When the DateFormat is an empty string, which is the default, the culture's default format is used. A user can also insert or change a date with the keyboard, then the TextControl tries to parse the inserted date depending on the specified format and culture and automatically formats the date. When parsing is not possible the previous date is restored.

function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

function inspectDateFormField(dateFormField) {
    dateFormField.getDate(
        function(result) {
            console.log("get date result:", result);
        },
        onTxError
    );
}

Members

Methods

MethodDescription
getDateGets the DateFormField's date.
getDateFormatGets 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.
getDescriptiveTextGets the form field's descriptive text. An empty string indicates that the link has no such text. (Inherited from FormField.)
getEmptyWidthGets the horizontal extension, in twips, of the date formfield, when it is empty.
getEnabledGets a value indicating whether the form field is enabled. (Inherited from FormField.)
getSupportedDateFormatsGets an array of format picture strings which can be used to format the date. The returned format strings depend on the culture set for the date field's text. A TextControl uses Day, Month, Year, and Era Format Picture strings to format a date.
setDateSets the DateFormField's date.
setDateFormatSets 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.
setDescriptiveTextSets the form field's descriptive text. An empty string or null can be used to delete a previously set text. (Inherited from FormField.)
setEmptyWidthSets the horizontal extension, in twips, of the date formfield, when it is empty.
setEnabledSets a value indicating whether the form field is enabled. This property has only an effect, when the when the edit mode is set to TXTextControl.EditMode.ReadAndSelect and the allowEditingFormFields property of the document permissions has been set to true. In this case a Formfield can only be edited, when its Enabled property is true. When a FormField is disabled, the TextFieldClicked and TextFieldDoubleClicked of the Formfield are suppressed. The default value of this property is true. (Inherited from FormField.)