Options
Option | HTML attribute | Type | Description |
---|---|---|---|
message |
data-fv-numeric-message |
String | The error message |
thousandsSeparator v0.7.0+ |
data-fv-numeric-thousandsseparator |
String | The thousands separator. The popular values are
|
decimalSeparator v0.7.0+ |
data-fv-numeric-decimalseparator |
String | The decimal separator. The popular values are
|
You don't need to do that when
i) using HTML 5 type="number" attribute,
ii) and the step attribute must be specified which its value is not an integer
The thousandsSeparator
and decimalSeparator
options are useful
if your country use particular separators for thousands and decimal parts. See the next
supporting locales section for more details.
If you want the value to support more special formats, you should use the transformer option. The modifying the value before validating example is good starting point.
Supporting locales
The thousands and decimal separators might take different value in certain countries. The following table introduces some popular values that are defined by various countries.
You can click the sample number to test:
Country | Thousands separator | Decimal separator | Valid ejemplos | Invalid ejemplos |
---|---|---|---|---|
An empty string | A dot (. ) |
|||
United States | A comma (, ) |
A dot (. ) |
||
France | A blank space | A comma (, ) |
||
Italy | A dot (. ) |
A comma (, ) |
The example also uses the updateOption() method to set
values for thousandsSeparator
and decimalSeparator
options.
Related validators
The following validators might be useful to you: