Skip to main content
hema.mathivathanan
November 28, 2023
Solved

validations

  • November 28, 2023
  • 11 replies
  • 0 views

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?

    Best answer by stewart.burchell

    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
    November 28, 2023

    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
    November 28, 2023

    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
    November 28, 2023

    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.