Restricting user from entering text after certain character limit

Certified Senior Developer

Hi all,
We have a business requirement where the user will enter data into a text field and if the data reaches a certain character limit say 100, we should not allow users to type more than 100. Like they want it to be freezed or stopped at 100 character length? We are showing character limit validation but they want some kind of restriction. Is it possible to achieve to such feature?

  Discussion posts and replies are publicly visible

Parents
  • I have found it LARGELY sufficient to simply utilize Appian's newer, built-in "character limit" functionality with "show character limit" turned ON.

    It does not physically STOP users from entering more characters than the limit, but it is VERY visible and makes it VERY easy for the user to comply.

    If you MUST have something like you describe (which i'd be curious to hear the business owners' rationale behind), then a solution like HARSH posted above but with "refresh after keypress" turned on, will be your closest option.  It won't work perfectly though.  (You can use the character limit visibility to your advantage here too).

    Edit: actually "refresh on keypress" doesn't help a whole lot here - either way, here's my revised code (shortened the limit temporarily for easier testing)

    a!localVariables(
      local!description,
      local!limit: 20,
      
      a!textField(
        label: "Description",
        instructions: "You can only add " & local!limit & " characters in this field, system will auto trim the characters after 100th character",
        value: local!description,
        refreshAfter: "KEYPRESS",
        characterLimit: local!limit,
        showCharacterCount: true(),
        saveInto: {
          a!save(local!description, left(save!value, local!limit))
        }
      )
    )

Reply
  • I have found it LARGELY sufficient to simply utilize Appian's newer, built-in "character limit" functionality with "show character limit" turned ON.

    It does not physically STOP users from entering more characters than the limit, but it is VERY visible and makes it VERY easy for the user to comply.

    If you MUST have something like you describe (which i'd be curious to hear the business owners' rationale behind), then a solution like HARSH posted above but with "refresh after keypress" turned on, will be your closest option.  It won't work perfectly though.  (You can use the character limit visibility to your advantage here too).

    Edit: actually "refresh on keypress" doesn't help a whole lot here - either way, here's my revised code (shortened the limit temporarily for easier testing)

    a!localVariables(
      local!description,
      local!limit: 20,
      
      a!textField(
        label: "Description",
        instructions: "You can only add " & local!limit & " characters in this field, system will auto trim the characters after 100th character",
        value: local!description,
        refreshAfter: "KEYPRESS",
        characterLimit: local!limit,
        showCharacterCount: true(),
        saveInto: {
          a!save(local!description, left(save!value, local!limit))
        }
      )
    )

Children