NumberField widget enables the creation of input fields that should contain a numeric value. It also provides formatting facilities to handle numeric and currency patterns.
label : "Please enter a decimal number:",
mandatory : true,
errorMessages : [ "Please type in a number" ]
The whole list of configuration parameters is available in
You can use formatting patterns to specify how a number should be conventionally displayed, even as a currency. It can be defined as a combination of the following:
|#||Number||Digit, zero shows as absent|
|¤ (\u00A4)||Prefix or suffix||Currency sign, replaced by currency symbol.|
The following sample shows how to create and use a NumberField widget, with a mandatory attribute for error checking and number format patterns. In order to fetch the entered value, variable binding is to be considered as the preferred solution. Please refer to the TextField widget for more informations.
In this sample, the first 3 NumberFields are the same except for the state, which is respectively mandatory, normal and disabled. The fourth NumberField has a pattern, that is used both to interpret and display the number.
More information about the pattern are available at Localization and Resources.