Skip to content

Characters from formatting count towards maxLength for Input fields #4312

Open

Description

@Gunnar-Solli-Olsen

Description of the bug

Characters from formatting count towards maxLength for Input fields, this causes the count of remaining symbols to be incorrect. The following image shows an input field that should say "Du har 7 tegn igjen", it shows 0 due to formatting inserting spaces for numbers, and two punctuations.

Image

Additionally formatting characters count towards the maxlength without accounting for characters consumed by formatting, adjusting to account for maximum length causes maxLength to initially be too large.

Image

Correct behaviour would be to store input to formatted number separately from visual formatting, read maxLength from input while applying format visually.

Steps To Reproduce

  1. Make blank page in altinn studio
  2. Use input field with both formatting and maxLength

Additional Information

Code for field shown:

  {
    "id": "S08-Input-Kontonummer",
    "type": "Input",
    "textResourceBindings": {
      "title": "S08-Input-Kontonummer.Title",
      "description": "S08-Input-Kontonummer.Description"
    },
    "dataModelBindings": {
      "simpleBinding": {
        "field": "FlatData.Kontonummer",
        "dataType": "DataModel"
      }
    },
    "formatting": {
      "number": {
        "format": "####.##.#####",
        "allowLeadingZeros": true
      }
    },
    "required": true,
    "maxLength": 13
  },

Activity

  1. added
    kind/bug
    on Jun 25, 2026
  2. Gunnar-Solli-Olsen commented on Jun 30, 2026

    @Gunnar-Solli-Olsen
    Author

    maxLength is superfluous when using "formatting", this limits the length of inputs by itself. Subtext with remaining characters still behaves strange when combining maxLength and formatting. Showing amount of remaining characters could be added as an option to "formatting".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugstatus/triage

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions