Search code examples
powerappspowerapps-formulapowerapps-canvas

How to Change 0 to 1 in TextInput


What is the best approach to change 0 to 1 on a PowerApps TextInput. Trying to figure out with OnSelect Function. Don't want a user to input a 0 Quantity to an order. If a user type in 0 it will automatic change to a 1

enter image description here

Hope l explain myself clearly. Thank you in advance.


Solution

  • You cannot, today, have a rule that will update the value of a control based on the value of the same control (as this may create a cyclical dependency). What you can do is to show to the user an error saying that they have made an error, and possibly prevent them from advancing in the app, like in the example below:

    Input validation

    To make that example, I updated the following properties in the screen control:

    btnAdd.DisplayMode: If(Value(TextInput1.Text) >= 1, DisplayMode.Edit, DisplayMode.Disabled)
    lblErrorMessage.Visible: Value(TextInput1.Text) < 1
    txtQuantity.BorderColor: If(Value(TextInput1.Text) >= 1, RGBA(0, 18, 107, 1), Color.Red)
    

    Hope this helps!