Demos
Locale based numbers
When you use as_number
or as_percent
(and as_currency
see below) it will create a mask for you and inherit the locale from the Eufemia Provider, if the locale prop is not given.
You can still define extra mask parameters with number_mask
or mask_options
, as the second input example shows (e.g. decimalLimit
).
<FormRow vertical><InputMaskedlabel="Number:"as_numbermask_options={{allowNegative: false,}}value="1234.50"rightbottomon_change={({ numberValue }) => {console.log(numberValue)}}/><InputMaskedlabel="Number (decimal limit):"as_numbernumber_mask={{decimalLimit: 2,}}value="1234.016"rightbottomon_change={({ numberValue }) => {console.log(numberValue)}}/><InputMaskedlabel="Percentage:"as_percentnumber_mask={{decimalLimit: 1,}}value="1234.016"rightbottomon_change={({ numberValue }) => {console.log(numberValue)}}/></FormRow>
as_currency
Locale based When you use as_currency
it will create a mask for you and inherit the locale from the Eufemia Provider, if the locale prop is not given.
<FormRow vertical><InputMaskedlabel="Currency:"as_currency="EUR"value="1234.50"on_change={({ numberValue }) => {console.log(numberValue)}}rightbottom/><Providerlocale="en-GB"InputMasked={{currency_mask: {decimalLimit: 3,},}}><InputMaskedlabel="Currency:"as_currency="USD"value="1234.567"on_change={({ numberValue }) => {console.log(numberValue)}}rightbottom/></Provider></FormRow>
currency_mask
manually
Define the <FormRow vertical><InputMaskedlabel="Left aligned (default):"show_maskcurrency_mask="kr"on_change={({ numberValue }) => {console.log(numberValue)}}rightbottom/><InputMaskedlabel="Right aligned:"show_maskcurrency_mask={{currency: 'NOK',}}align="right"on_change={({ numberValue }) => {console.log(numberValue)}}/></FormRow>
Customize the number mask
<InputMaskedlabel="Masked amount:"show_masknumber_mask={{suffix: ' kr',allowDecimal: true,}}placeholder_char={null}on_change={({ numberValue }) => {console.log(numberValue)}}/>
number_mask
with a combined suffix
Using the kr
<InputMaskedlabel="Masked input:"value="1000000"number_mask={{suffix: ',-',allowDecimal: false,}}suffix="kr"on_change={({ numberValue }) => {console.log(parseInt(numberValue || 0, 10))}}/>
number_mask
and a prefix
Using the <InputMaskedlabel="Masked input:"number_mask={{prefix: 'NOK ',}}stretch={true}placeholder="Enter a number"on_change={({ numberValue }) => {console.log(numberValue)}}/>
Phone Number, starting with 4
<InputMaskedlabel="Masked input:"mask={['0','0',/[4]/,// have to start with 4/[5-7]/,// can be 5,6 or 7' ',/[49]/,// have to start with 4 or 9/\d/,' ',/\d/,/\d/,' ',/\d/,/\d/,' ',/\d/,/\d/,]}show_maskplaceholder_char="_"keep_char_positionson_change={({ numberValue }) => {console.log(numberValue)}}/>