Restrict User Input in a Field to a certain range

Hi

 

I want to get user input in a certain line item related to number format but want to restrict the user input between 0 and 100. If the value input is between 0 to 100 then this value must be used as it is. But if the user input is <0 or >100 then it should return an error or must convert the value directly to the limit.

 

Summarised as follows:

User input = x

Case 1: if x >= 0 and x <= 100 then use x as it is.

Case 2: if x < 0 or x > 100 then either return an Error or change the value to x = 0(for x < 0) and x = 100(for x > 100).

Answers

  • @mohitveer_sandhu 

     

    You can not do any of that sort in the user input line item. Instead you can create another line item which will take the values from user input line item and you can write below logic in the second line item.

     

    If X < 0 Then 0 else if X > 100 Then 100 ELSE X  ELSE X

     

    Misbah

  • @mohitveer_sandhu 

    You can break it up into 2 line items:

    1. User input

    2. Evaluate if the value is above/below max/min thresholds (ex: IF input >= 0 AND input <= 100 THEN input ELSE IF input < 0 THEN 0 ELSE 100) - something of that nature should allow you to use the second line item as your main reference for any subsequent formulas.

    Let me know if you have any questions.

  • Is there any way to define error instead of reassigning the value?

  • @mohitveer_sandhu,

     

    Have one more text or list formatted line item that shows the error message based on the user input.

    The logic remains as If X < 0 Then "not valid" else if X > 100 Then "not valid" ELSE "valid".

    I would suggest you to use conditional formatting to highlight the input error.

     

     

    Thanks,

    Sandeep

  • Yep, as @sandeep_bk mentioned, conditional formatting would alert the end users that the input is invalid.

    You can create a separate line item that evaluates 0 or 1 to determine if its valid. Then apply conditional formatting, with red indicating an error.

  • The best approach here would be to use a list.
    Create a list using 1 - 100 with a property formatted as number from 1 - 100.
    Format your input with the list and create a additional line item formatted as number. Reference the list property so that you can convert the list selection to a number format to use in down stream calculations.
    This would be the easiest and simplest approach. However, you will not be able to set a default and will have to use one of the other methods if this is still required.

    Thanks,
    Chris