[Custom Input Masks] Mask expression to allow negative and positive decimal values
Question
Forge component by Sara Gonçalves

Hi ,

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


Thanks .

mvp_badge
MVP
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 

Champion

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}"
Champion

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.

mvp_badge
MVP
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 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.