Skip to main content
udayasain741
November 10, 2022
Solved

how to validate a text field which can be A,B,C,D, Null, or groups of A,B,C,D (ex. ‘A,B,C’ with commas no space).

  • November 10, 2022
  • 3 replies
  • 0 views

how to validate a text field which can be  A,B,C,D, Null, or groups of A,B,C,D (ex. ‘A,B,C’ with commas no space).

    Best answer by mikes0011

    my quick suggestion:

    a!localVariables(
      local!text,
      
      a!textField(
        value: local!text,
        saveInto: local!text,
        validations: {
          if(
            and(
              a!isNotNullOrEmpty(local!text),
              a!isNotNullOrEmpty(stripwith(local!text, "ABCD,"))
            ),
            "invalid characters entered",
            ""
          )
        }
      )
    )

    3 replies

    mikes0011
    Brainy
    November 10, 2022

    i'd be curious to see what you've tried so far and what works / doesn't work?

    The Expression Guru
    mikes0011
    mikes0011Answer
    Brainy
    November 10, 2022

    my quick suggestion:

    a!localVariables(
      local!text,
      
      a!textField(
        value: local!text,
        saveInto: local!text,
        validations: {
          if(
            and(
              a!isNotNullOrEmpty(local!text),
              a!isNotNullOrEmpty(stripwith(local!text, "ABCD,"))
            ),
            "invalid characters entered",
            ""
          )
        }
      )
    )

    The Expression Guru