Registry / productivity / auto-formatter

auto-formatter

JSON →
library0.1.0jsnpmunverified

auto-formatter is a browser-based library that formats input fields as you type, supporting phone numbers (e.g., (XXX) XXX-XXXX, XXXXX-XXXXX), credit card numbers (XXXX XXXX XXXX XXXX), and dates (DD/MM/YYYY, MM/DD/YYYY, YYYY/MM/DD). Version 0.1.0, released in 2015, is the sole and final version. It is a simple, dependency-free solution for client-side formatting, using a pattern-based approach with optional left-to-right (LTR) or right-to-left (RTL) direction, max length limiting, and recurring pattern support. The package has not been updated since 2015 and remains in maintenance mode. Key differentiator: zero dependencies and a straightforward API for real-time formatting without complex configuration.

npm install auto-formatter
INSTALL
IMPORT
SIG · AUTO-FORMATTER
A
auto-formatter
productivityjavascriptv0.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AutoFormatter
var formatter = new AutoFormatter({ targetNode: el });
const { AutoFormatter } = require('auto-formatter');
This is a global constructor attached to window when loaded via <script>. Not a module. Must be used in browser environment.
AutoFormatter.format
AutoFormatter.format({ value: '1234567890', format: 'XXX-XXX-XXXX' });
AutoFormatter.format('1234567890', 'XXX-XXX-XXXX');
The static format method expects an options object, not positional arguments.
AutoFormatter instance methods
formatter.enableFormatting(); formatter.disableFormatting();
AutoFormatter.enableFormatting();
enableFormatting and disableFormatting are instance methods, not static.

Demonstrates initializing AutoFormatter on an input element and using the static format method.

<input type="tel" id="phone" value="1234567890" data-format="(XXX) XXX-XXXX"> <script src="https://unpkg.com/auto-formatter@0.1.0/auto-formatter.js"></script> <script> var input = document.getElementById('phone'); var formatter = new AutoFormatter({ targetNode: input, limitToMaxLength: true }); formatter.enableFormatting(); // Static usage: var formatted = AutoFormatter.format({ value: '1234567890', format: 'XXXXX-XXXXX' }); console.log(formatted); // "12345-67890" </script>
Debug
Known issues
gotchaThis package is not available as an npm module for import/require; it is only a browser global (window.AutoFormatter).
fix
Use a <script> tag from unpkg or include the file manually. Do not attempt to import via ES modules or CommonJS.
affects: >=0.0
deprecatedThe package has not been updated since 2015 and is considered in maintenance mode. No future updates are expected.
fix
Consider migrating to a modern alternative like Cleave.js or IMask for ongoing support and features.
affects: 0.1.0
gotchaThe static method AutoFormatter.format does not return the formatted string; it returns undefined. The formatted value is not returned or logged.
fix
The method appears to have no return value in the source. Use the instance method with a target node instead to see formatted output in the input.
affects: 0.1.0
Errors
Common errors & fixes
Uncaught ReferenceError: AutoFormatter is not defined
Script not loaded or loaded after usage attempt.
fix
Ensure <script src="path/to/auto-formatter.js"> is placed before any code using AutoFormatter.
AutoFormatter is not a constructor
Using import/require in a Node.js environment or bundler without proper script loading.
fix
Load via <script> tag in browser; the package does not export a module.
Uncaught TypeError: Cannot read properties of null (reading 'querySelector')
targetNode passed to constructor is null/undefined or not a DOM element.
fix
Verify the selector matches a valid DOM element before instantiation.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
35 hits · last 30 days
node
28
OpenAI (training)
1
Resources
auto-formatter — npm install auto-formatter · libregistry