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:
|
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); }