@tremendous/help
    Preparing search index...

    Function maskUsPostalCode

    • Strips characters a US postal code can never contain, so invalid input never renders. Keeps the hyphen, which ZIP+4 needs. Non-US postal codes must not be passed through this — many are alphanumeric.

      Parameters

      • postalCode: string

        The raw input to mask.

      Returns string

      The input with everything but digits and hyphens removed.

      maskUsPostalCode("abc33132"); // "33132"
      maskUsPostalCode("33132-3204"); // "33132-3204"