Skip to main content
September 19, 2025
Question

TextField Validation

  • September 19, 2025
  • 4 replies
  • 0 views

Hi,

Can you please help me how to give validation to the Textfield, where it should accept only Alphabets.

If any special characters or numbers entered it should throw an validation error message.

Is there any function is there?

4 replies

mikes0011
Brainy
September 19, 2025

you probably want to utilize the "clean()" function, which strips any nonprintable characters from input text.  If you wish to STRICTLY only support letters (not numbers, not anything else), then you can pivot to "cleanWith()", which allows you to set the list of acceptable characters.

Using this you can then choose between 2 methods:

  1. easiest, sanitize the user's input as they input it.  don't bother with validaiton at all.
  2. instead, you could use the funciton in your validation, and check whether the input string is different from the string when invalid characters are removed, and if so, show a validation message.
mikes0011
Brainy
September 19, 2025

e.g.

September 19, 2025

Hi. You could try this:

a!localVariables(
  local!test,
  {
    a!columnsLayout(
      columns: {
        a!columnLayout(
          contents: {
            a!textField(
              label: "Text",
              labelPosition: "ABOVE",
              value: local!test,
              saveInto: {
                local!test
              },
              refreshAfter: "UNFOCUS",
              validations: {
                if(
                  regexmatch(
                    pattern: "^[a-zA-Z]+$",
                    searchString: local!test
                  ),
                  null,
                  "Only alphabetic letters (Aâ`“Z) are allowed."
                )
              }
            )
          }
        ),
        a!columnLayout(
          contents: {}
        ),
        a!columnLayout(
          contents: {}
        )
      }
    )
  }
)

September 24, 2025

se puede realizar la validación por medio de expresiones regulares con la función:

a!matchRegex(a!matchRegex(
pattern: "^[0-9]{10}$", /* Solo números de 10 dígitos */
value: "3214567890"value: "3214567890"
))