In the Mobilengine form language, number formatting rules specify how numbers from data-binding expressions or user input should be parsed.
Usage
<numberbox
...
numberFormat='{
decimalSeparator:decimalSeparator
groupSeparator:groupSeparator
maxFraction:maxFraction
groupSize:groupSize
prefix:prefix
postfix:postfix}'
.../>Parameters
| Parameter | Description |
|---|---|
| decimalSeparator (required) | The string character that separates the integer part from the fractional part of a floating point number. |
| groupSeparator | The digit group separator string character (e.g. [space],
",", ".", "'"). The default value is
".".
|
| maxFraction | The integer that
specifies the maximum allowed number of decimal digits. The default value is
2.
|
| groupSize | The integer that
specifies the number of digits in a digit group. The default value is
3.
|
| prefix | A string
that will be displayed as a prefix to the immediate left of the numberbox
control. The default value is an empty string.
|
| postfix | A string
that will be displayed as a postfix to the immediate right of the numberbox
control. The default value is an empty string.
|
Remarks
The decimalSeparator attribute is required even
if the number format is associated with a numberbox control whose
float field is set to false.
Sample
...
<numberbox id='numboxPtoo'
numberFormat='{decimalSeparator: "#",
maxFraction: 4,
groupSeparator:"&",
groupSize: 3,
prefix:"USD",
postfix:"in small bills, please"}'
float="true"
invalidNumberMessage="Almost. Not quite, though."/>
<numberbox id='numboxHsoo'
numberFormat='{decimalSeparator: "@",
maxFraction: 1,
groupSeparator:" ",
groupSize: 3,
prefix:"USD"}'
float="true"
invalidNumberMessage="Almost. Not quite, though."/>
...
Figure 302. Because of the quirky numberFormat settings, the unconventional input
in the top numberbox in the screenshot is successfully parsed as a number,
while the conventional-looking input in the bottom numberbox throws a
parsing error
...
<numberbox id='numboxPtoo'
numberFormat='{decimalSeparator: "#",
maxFraction: 4,
groupSeparator:"&",
groupSize: 3,
prefix:"USD",
postfix:"in small bills, please"}'
float="true"
invalidNumberMessage="Almost. Not quite, though."/>
...
<textview text='{FORMATNUMBER(numboxPtoo.number,
{decimalSeparator:" here come the decimals ",
groupSize:3,
groupSeparator:"green bottles",
maxFraction:5,
prefix:"I would like to have ",
postfix:" units of legal tender, please."})}'/>
...
Figure 303. When numeric input is parsed to a string, the numberFormat that is
applied later overrides the original formatting rules in the
numberbox


