1
0
-1

We need to be able to limit the user to only entering certain characters into a text field.

Is there a way to do this in the current component?

If not, is there a way to implement this?

For example:

  • can we use the KeyPress event?
  • another way to do this might be to create a sub-class of the Text Field component, as a native component. Then you can add a property to control the format or the allowed characters or whatever you want.
  • Or build a new native component?
  1. Miroslav Botka

    Would this be accessibility standards compliant? Maybe not a requirement in your case Howard, however one to keep it mind for any other mates using this technique.

  2. Bill Frost

    It might also be worth considering a masking approach, but that would depend on the specific requirement.

  3. Howard Treisman

    Internal discussion has resulted in the following suggestion:

    The cleanest way to do this in Maestro, is to create another native component based on text-input, this will have its own JavaScript file containing its own directive. It will also contain a html file that references this directive. The directive will handle the logic.

    I have asked for an article to be written to explain how to do this.

  4. Howard Treisman

    In addition, if you're careful, you can organize it so that:

    • your new component descends from the existing Text Entry component
    • you place your new component higher in the library hierarchy

    This will effectively mean that the new component replaces the standard component. And all components that descend from the Text Entry widget will also inherit the new behavior.

CommentAdd your comment...

1 answer

  1.  
    1
    0
    -1

    There is a core native component now that offers that as a side-effect, the 'autotab block'.

    It allows a Format regex to enforce a custom set of allowed characters, although this was not its primary intended function.

      CommentAdd your comment...