294
Views
4
Comments
Solved
Check if 0 is in input field
Question
Application Type
Mobile

I have an number input field in a container.  When they trigger an action, I want to be able to tell if they didn't enter anything or if they entered 0.  For this form I need them to enter something, and that number CAN be 0, but they can't enter nothing.  Not sure how to tell the difference between and entered 0 and nothing entered.  Any help would be appreciated.

UserImage.jpg
David McCulloch
Solution

Now that I posted this, I found the solution.

Outsystem checked the value and couldn't tell the difference between null and 0.

So I just used Javascript to check the value length (since null is 0 and 0 is 1).

Then I saved that value and when the input was brought back to the screen I set the inputs value back to 0 if that is what they entered.

UserImage.jpg
Ahmed El-farrash

How did you put 0 in the input after rendering ? 
on my side i want to show 0 but it shows empty widget

2020-07-01 11-36-23
Shubham Tiwari

Hi David, Can you please explain in detail with a screenshot or share the oml?

UserImage.jpg
David McCulloch
Solution

Now that I posted this, I found the solution.

Outsystem checked the value and couldn't tell the difference between null and 0.

So I just used Javascript to check the value length (since null is 0 and 0 is 1).

Then I saved that value and when the input was brought back to the screen I set the inputs value back to 0 if that is what they entered.

UserImage.jpg
Ahmed El-farrash

How did you put 0 in the input after rendering ? 
on my side i want to show 0 but it shows empty widget

2020-07-01 11-36-23
Shubham Tiwari

That's good work there David.

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