JavaScript

{dialog.object}getDateValue Method

Syntax

var d = {dialog.object}.getDateValue(ControlId);

Arguments

ControlIdstring

The name of the control to get the value and return as a date object.

Returns

dDate

Returns the value of the specified control parsed as a date object.

Description

Get the value of a control in the UX Component as a JavaScript Date object.

Discussion

When you use the .getValue() method to retrieve the value of any control, a string is returned, regardless of the control's defined data type. In the case of numeric and logical types, casting the value to the required JavaScript type is easy (using the $u.s.toNum() or $u.s.toBool()) functions, but casting to a date value is harder because the data value has to be parsed. The .getDateValue() method can be used to get the value from a control in the UX Component as a JavaScript Date object.

Note: If you have defined a custom date format for a textbox and the custom format does not match the Default date format (set in the Other section on the Properties pane in the UX builder), the date value is now normalized to use the Default date format. Previously, the .getValue() method returned the value using the custom format defined for the textbox.

If you want to revert to this old behavior, you can disable normalization by adding the following command to the client-side onRenderComplete event:

For example:

function setShipDate() {
    var orderDate = {dialog.object}.getDateValue('orderDate');

    var shipDate = orderDate.addTime('week',1);
    {dialog.object}.setValue('shipDate', shipDate.toFormat("MM/dd/yyyy"));
}

The date string in the control is parsed into a date object using the client-side date and time format defined in the UX component.

See Also