466
Views
16
Comments
Solved
[Custom Input Masks] How to input number 0 to an input using MaskNumber?
custom-masks
Web icon
Forge asset 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!

2018-12-10 12-16-21
Goncalo Duarte Almeida
Solution

Hi Hoi Dinh Huu

Check the file if is the expected behavior.

Regards

Gonçalo Almeida

CustomMaskDemo.oml
UserImage.jpg
Hoi Dinh Huu
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!

UserImage.jpg
Hoi Dinh Huu
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!

2021-06-01 05-56-33
Komal Kumbhar

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
UserImage.jpg
Hoi Dinh Huu

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
2021-06-01 05-56-33
Komal Kumbhar

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
UserImage.jpg
Hoi Dinh Huu


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

2021-06-01 05-56-33
Komal Kumbhar

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>
"
2024-01-31 05-29-41
Akshay Deshpande

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
UserImage.jpg
Hoi Dinh Huu

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

2018-12-10 12-16-21
Goncalo Duarte Almeida

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
UserImage.jpg
Hoi Dinh Huu


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

2019-04-29 15-49-13
Detlev

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

UserImage.jpg
Hoi Dinh Huu

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

2020-01-08 08-43-00
Rahul Kumar

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.

UserImage.jpg
Hoi Dinh Huu

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

2018-12-10 12-16-21
Goncalo Duarte Almeida
Solution

Hi Hoi Dinh Huu

Check the file if is the expected behavior.

Regards

Gonçalo Almeida

CustomMaskDemo.oml
UserImage.jpg
Hoi Dinh Huu
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!

2018-12-10 12-16-21
Goncalo Duarte Almeida

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.