[Custom Input Masks] How to input number 0 to an input using MaskNumber?
Forge component by Sara Gonçalves
Application Type
Traditional Web

I have an input widget. I set default value: -999 and Null Value: -999

When I input number 0 to this input box, the variable associated with this input widget does not receive value 0.

How can I fix this? I want number 0 will be assign to the variable when I enter 0 into the input box.

Thanks!

Hi Hoi Dinh Huu

Check the file if is the expected behavior.

Regards

Gonçalo Almeida

CustomMaskDemo.oml

Solution

I still using MaskNumber, but I set AdvancedOptions is "{placeholder: ''", and now the input can accept 0 value.

I don't know why placeholder affected the null value of input widget.

Thank you so much!

Solution

I still using MaskNumber, but I set AdvancedOptions is "{placeholder: ''", and now the input can accept 0 value.

I don't know why placeholder affected the null value of input widget.

Thank you so much!

Hi,

Can you please share the details that you given for custom mask input, as you mentioned I tried to create and it's working fine, for your reference I have attached OML,

Have a look here - https://komal-k.outsystemscloud.com/CustomMaskDemo/Demo.aspx

Regards,

Komal

CustomMaskDemo1.oml

I attached my program, and here is my link: https://hoidh.outsystemscloud.com/CustomMaskDemo/Entry1.aspx

I set the input widge mandatory, then I input 0 into Salary field, it still gets a blank value and does not pass the validation when I click Submit.

CustomMaskDemo.oml

Hi,

If the data type is integer then zero is not acceptable but if the data type is decimal and when you enter  0.00 then it is accepting the value for both salary and Age. 

I have attached the OML,

Regards,

Komal

CustomMaskDemo.oml


Thanks for your help, but I want the data type is integer and 0 is acceptable :)

You can use this script to accept only numbers from 0-9 instead of masknumber component 

"<script>
$(function() {
     $('#"+WidgetId+"').on('input', function() {       
         this.value = this.value
         .replace(/[^0-9]/, '');      
        });
});
</script>
"

Hello Hoi Dinh huu,

here I Attached OML and link for your reference. this will help you to solve your problem

Link - https://akshayproject.outsystemscloud.com/Forum/Masking.aspx


Forum.oml

If the input is mandatory, it doesn't work when I type 0 to the input box.

Hi Hoi Dinh Huu.

Check if this solution works for you.

Basically, I defined the mask to allow numbers >= 0. It doesn't let you insert negative values.

Regards

Gonçalo Almeida


CustomMaskDemo.oml


I want the input accept negative, 0 and positive. I also want to format the display of the number like that: 1000 => 1,000

If I can remember correctly you can state the nill-value in the input field. If you set it to -1 (for example) you can validate a zero

Yes, I set Null Value is -1, but when I input 0 to the input box, it is not acceptable.

Hi  Hoi Dinh Huu,

JS written for this component may be not privilege to take 0 as input. That's why it is taking integers except 0.

It's better to use Regex_Search Server Action. Where you can defined your  regex patter for input.

You can use:   

/^[-+]?[0-9]\d*$/

for your search.


 

Thank you.

I not only want to validate this field but also want to format the display of the number.

Hi Hoi Dinh Huu

Check the file if is the expected behavior.

Regards

Gonçalo Almeida

CustomMaskDemo.oml

Solution

I still using MaskNumber, but I set AdvancedOptions is "{placeholder: ''", and now the input can accept 0 value.

I don't know why placeholder affected the null value of input widget.

Thank you so much!

Ok. You can use it according to your use case.

Is affected because the placeholder is some kind of default value that is overridden the default value from the input.

Glad I could help.

If it is closed please mark this as "Solution" in order to close this thread.

Regards

Gonçalo Almeida

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