Skip to main content
hema.mathivathanan
Employee
Nov 28, 2023 3:59 PM UTC
Solved

validations

Hi, I need a validation that the user can enter only numbers from 01-99 . How can we do this?
Is there any range function or limit function to check it?

    stewart.burchell
    Employee
    Nov 28, 2023 4:08 PM UTC

    Assuming the field you're using to capture the data is an Integer field you can write a validation on that field:

    {
      a!integerField(
        label: "Integer",
        labelPosition: "ABOVE",
        value: ri!myInteger,
        saveInto: {
          ri!myInteger
        },
        refreshAfter: "UNFOCUS",
        validations: {
          if(
            fn!or(
              ri!myInteger<0,
              ri!myInteger>99
            ),
            "Invalid value - out of range (0-99)",
            null
          )
        }
      )
    }

    11 replies

    stewart.burchell
    Employee
    Nov 28, 2023 4:08 PM UTC

    Assuming the field you're using to capture the data is an Integer field you can write a validation on that field:

    {
      a!integerField(
        label: "Integer",
        labelPosition: "ABOVE",
        value: ri!myInteger,
        saveInto: {
          ri!myInteger
        },
        refreshAfter: "UNFOCUS",
        validations: {
          if(
            fn!or(
              ri!myInteger<0,
              ri!myInteger>99
            ),
            "Invalid value - out of range (0-99)",
            null
          )
        }
      )
    }

    hema.mathivathanan
    Employee
    Nov 28, 2023 4:23 PM UTC

    I use a text field and user can enter a value a list from 01-99. Is it possible to use regexallmatches for this to validate and get the correct  values 

    stewart.burchell
    Employee
    Nov 28, 2023 4:28 PM UTC

    As long as you can find the correct RegEx expression then yes. I would encapsulate the RegEx in a separate Expression Rule so you can test it independently from the User Interface, and then simply incorporate it into the Interface when it's ready.