Skip to main content
Participating Frequently
Jan 2, 2023 5:52 AM UTC
Question

validation for text field

hi,

i use 22.3 version

i have an condition in text field 

in that i want only alphabetical character (A-Z) not numerical or special character

how to do that

    5 replies

    Inspiring
    Jan 2, 2023 6:53 AM UTC

    You can use regexMatch function to make it according to regex. But for than you have to deploy Regex expression plugin in your environment

    harshitb6843
    Brainy
    Jan 2, 2023 7:01 AM UTC

    If you do not want to add a dependency on the plugin, then you can use this code. 

    if(
      and(
        a!forEach(
          items: code(ri!name),
          expression: or(
            and(fv!item >= 65, fv!item <= 90),
            and(fv!item >= 97, fv!item <= 122)
          )
        )
      ),
      {},
      "Cannot contain numbers or special characters"
    )

    Known Participant
    Jan 2, 2023 7:09 AM UTC

    you can try this.

    if(
    contains(
    cast(
    runtimetypeof(ri!input),
    stripwith(
    cleanwith(
    ri!input,
    joinarray(
    {
    "abcdefghijklmnopqrstuvwxyz",
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    }
    )
    ),
    " "
    )
    ),
    ri!input
    ),
    "",
    "Please use alphabetical characters only."
    )

    harshitb6843
    Brainy
    Jan 2, 2023 7:12 AM UTC

    Simplified it a bit. 

    if(
      a!isNotNullOrEmpty(
        stripwith(
          ri!name,
          lower("ABCDEFGHIJKLMNOPQRSTUVZXYZ") & "ABCDEFGHIJKLMNOPQRSTUVZXYZ"
        )
      ),
      "Can only contain alphabets",
      {}
    )

    Known Participant
    Jan 2, 2023 7:14 AM UTC

    cool, :)