[Custom Input Masks] Mask expression to allow negative and positive decimal values

Forge Component
(37)
Published on 22 Apr by Marcelo Ferreira
37 votes
Published on 22 Apr by Marcelo Ferreira

Hi ,

I need to allow negative decimal values as well in my text box . What mask expression should I use??


Thanks .

https://regex101.com/r/YTiDc4/2

This regex:

 ^[-+]?[0-9]\d*(\.\d+)?$

Allows you to match on decimals, positive and negative (it also accepts + symbols).

You can use regex in the advancedoptions or by adding  data-inputmask-regex to the extended properties of the input.

Hi Joey,

Thanks for you help. I was looking for expression that can be used in this tool. I got one .

SyntaxEditor Code Snippet

"(-){0,1}9{0,12}(.9{0,2}){0,1}"

Pranav Pandey wrote:

Hi Joey,

Thanks for you help. I was looking for expression that can be used in this tool. I got one .

SyntaxEditor Code Snippet

"(-){0,1}9{0,12}(.9{0,2}){0,1}"

I think you can just use 'decimal' as maskdefinition directly instead....
This component got a few options like allowminus, allowplus, so there's no need to use a extensive format like that.

Solution

Hi Pranav,

To accomplish that you just need to use the MaskNumber and define how many decimal digits you want. The positive and negative is done by default. You can check the try now for an integer example.

Regards,

Marcelo 

Solution