344
Views
4
Comments
Solved
[Custom Input Masks] Mask expression to allow negative and positive decimal values
Question
custom-masks
Web icon
Forge asset 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 .

2019-05-22 11-30-09
Marcelo Ferreira
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 

2017-12-13 08-27-28
Joey Moree

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.

2022-02-07 08-52-30
Pranav Pandey

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}"
2017-12-13 08-27-28
Joey Moree

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.

2019-05-22 11-30-09
Marcelo Ferreira
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.