Text format WHILE typing?

Hello, new with Appian here.

We have an account number text field on an interface screen. We would like the format of the entered values to follow this format "00-0000000".

I built a rule to display that format, but it only works AFTER the field has lost focus. I also tried refresh after keypress. It didn't seem to work.

Is there a way to have the "-" appear while a user is typing in the value? In this case it would show the "-" after they have typed in the first two digits and continue as they finish the rest of the digits. "12-" for example.

Thanks

  Discussion posts and replies are publicly visible

Parents
  • Welcome to the community!

    Unfortunately, in this case I do not believe that we will be able to manipulate the value that the user is inputting, until Appian thinks they are done inputting it (e.g., when the focus moves).  While refreshAfter="KEYPRESS" will update the underlying variable, and persist to other areas of the form immediately, it does update the currently-inputted text until the focus changes.

    Using this example interface:

    a!localVariables(
      local!account,
      
      a!textField(
        label: "Account #",
        value: local!account,
        refreshAfter: "KEYPRESS",
        saveInto: a!save(
          local!account,
          if(
            or(
              len(save!value)<3,
              index(save!value,3,"")="-"
            ),
            save!value,
            joinarray(
              insert(
                index(
                  save!value,
                  1+enumerate(len(save!value))
                ),
                "-",
                3
              )
            )
          )
        )
      )
    )

    You can see that the actual local!account variable which is used in the value of the textField, IS in fact being updated on each keypress, but the textField does not refresh the input to match until the focus is lost.  Even if we put the logic to display the "-" in the value parameter directly, it does not change the behavior.

    So, it might be a UX paradigm the users would have to get accustomed to unfortunately (as far as I am aware).

  • 0
    Certified Lead Developer
    in reply to Chris

    Yes I agree with what chris said, you can add a richTextField just below the text field that might help I am adding that to the code 

    a!textField(
        label: "Account #",
        value: local!account,
        refreshAfter: "KEYPRESS",
        saveInto: a!save(
          local!account,
          if(
            or(
              len(save!value)<3,
              index(save!value,3,"")="-"
            ),
            save!value,
            joinarray(
              insert(
                index(
                  save!value,
                  1+enumerate(len(save!value))
                ),
                "-",
                3
              )
            )
          )
        )
      ),
      a!richTextDisplayField(
        value: a!richTextItem(
          text: local!account
        )
      )

Reply
  • 0
    Certified Lead Developer
    in reply to Chris

    Yes I agree with what chris said, you can add a richTextField just below the text field that might help I am adding that to the code 

    a!textField(
        label: "Account #",
        value: local!account,
        refreshAfter: "KEYPRESS",
        saveInto: a!save(
          local!account,
          if(
            or(
              len(save!value)<3,
              index(save!value,3,"")="-"
            ),
            save!value,
            joinarray(
              insert(
                index(
                  save!value,
                  1+enumerate(len(save!value))
                ),
                "-",
                3
              )
            )
          )
        )
      ),
      a!richTextDisplayField(
        value: a!richTextItem(
          text: local!account
        )
      )

Children
No Data