[Custom Input Masks] Negative Percentage Values

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

Hello,

I am using the MaskPercentage option from the Forge Custom Input Masks component but I am unable to get it to accept negative percentage values (e.g. -50%) and store it to the database.  I am not having any issues with positive percentage values (e.g. 40%) on the same input field.  I need to allow values between -100% and +100%.

How do I get the mask to work with negative percentage values ?

Cheers, Richard.

Hi,

In the customMask percentage in the field advanced options you can use a regex expression, something like this:

"{regex:'"+ GetCustomMaskText() +"', placeholder: '' }", possibly will work.

The regex expression could be: ^-?(100([.]0{1,2})?)$|(^-?\d{1,2}([.]\d{1,2})?) .

Hope it helps :)


Nélio Dionisio wrote:

Hi,

In the customMask percentage in the field advanced options you can use a regex expression, something like this:

"{regex:'"+ GetCustomMaskText() +"', placeholder: '' }", possibly will work.

The regex expression could be: ^-?(100([.]0{1,2})?)$|(^-?\d{1,2}([.]\d{1,2})?) .

Hope it helps :)


Hi Nélio,

Thanks for the reply.  Unfortunately that is a bit beyond my current competency level - are you able to break it down for me a bit more ?

Cheers, Richard.

Solution

Hi Richard,

I have another idea, more simple. See if solves :) ?


Best Regards,

Nélio

Solution

Nélio Dionisio wrote:

Hi Richard,

I have another idea, more simple. See if solves :) ?


Best Regards,

Nélio

Hi Nélio,

I only needed to add "{allowMinus: true, min: -100}" and it worked, thank you !

Cheers, Richard.