TextField Validation

Certified Associate Developer

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?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    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.
Reply
  • 0
    Certified Lead Developer

    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.
Children