k2-input-formatter

K2 Input Formatter is a lightweight JavaScript library designed to enhance user experience in web forms through strict control and real-time automatic formatting of data. It transforms conventional input fields into specialized components that handle numbers with thousands separators and decimals, as well as date-time fields (dd/mm/yyyy hh:mm:ss), ensuring that entered data is always valid before submission. Among its key features are an advanced history system (undo/redo) based on WeakMap for memory optimization, automatic normalization when pasting text from the clipboard, and smooth keyboard navigation allowing users to jump between fields via the Enter key — offering a robust, intuitive, and format-error-free interface.

MIT License JavaScript Open Source
View on GitHub K2Sistemas-NET / k2-input-formatter
Numeric Field — Interactive example

Automatic thousands separator using a period. Use comma or the numpad period key as decimal separator.

Integer (no decimals, max 8):
2 decimals (max 10):
4 decimals (max 12):
🔢
Thousands separator
Automatically formats with periods while typing: 1.000.000
↩️
Undo / Redo
Independent Ctrl+Z and Ctrl+Y per field, up to 10 steps
📋
Smart paste
Automatically filters and reformats pasted text
🔒
Max digits
Controls the digit limit via the maxlength attribute
Date / Time Field — Interactive example

Format: dd/mm/yyyy hh:mm:ss. Type only the digits and press Enter to complete. Enter on each field moves to the next one.

Date 1:
Date 2:
Date 3:
📅
Auto formatting
Inserts / and : while typing. Just type the digits
Real-time validation
Red border if the date is invalid (e.g. 31/02/2026)
⌨️
Enter to complete
Fills empty fields with today's date when pressing Enter
↩️
Undo / Redo
Independent Ctrl+Z and Ctrl+Y per field