pp108 : format()

format()


It formats the value of the control based on the specified format.

Syntax

Script

control.format(oFormatType, bOverwriteFormat)


Parameters

Parameter

Description

oFormat

Object. Refers to the format object that contains thedataTypeand other formatting attributes. This object must be retrieved using thegetFormatType()method.

bOverwriteFormat

Boolean. Denotes whether the default format type can be overwritten by the user-specified format type. Possible values are:

  • true: The default format type on the control is overwritten by the specified format.
  • false: Default.


Return Value


It returnstrueif the formatting is successful. Returnsfalseif formatting of the value in the field fails.

Remarks


This method does not overwrite the default format type set on the control. The change in format applies to the current value only.

Example

function applyUsertFormat()
{
// Get the display format selected by user. say "DD/MM/YYYY".
    var userPreferenceFormat = userPreferenceDate.getValue();
// Get the Format Type of the sampleDate field.
    var sampleDateFormatType = sampleDate.getFormatType("date");
// Set the user preferred date format
    sampleDateFormatType.setDisplayFormat(userPreferenceFormat);
// Format the value in sampleDate field.
    sampleDate.format(sampleDateFormatType);
}

Applies to


Input, List, Output, Select, Textarea

Related reference

getFormatType()