detect-format-input-type
v1.0.4
Published
Lightweight input type detector and formatter for phone, Aadhaar, card and custom patterns
Maintainers
Readme
detect-format-input-type
Lightweight input type detector and formatter for common patterns like phone, Aadhaar, card, PAN, expiry, date, and Indian currency.
✨Features
- 📱 Phone formatting (
98765 43210) - 🆔 Aadhaar formatting (
1234 1234 1234) - 💳 Card formatting (
1234 5678 1234 5678) - 📅 Expiry date (
12/25) - 📆 Full date (
01/01/2024) - 🧾 PAN formatting (
ABCDE1234F) - 💰 Indian currency (
10,00,000) - 🔍 Auto detect & format
📦Installation
npm install detect-format-input-type🌐 Live Demo
JS👉 Try it here
📌 Supported Types
phoneaadhaarcardexpirydatepancurrency
🚀 Usage
🟨 JavaScript
const { formatInput, detectAndFormat } = require("detect-format-input-type");
// Phone
formatInput("9876543210", "phone");
// Aadhaar
formatInput("123412341234", "aadhaar");
// Card
formatInput("1234567812345678", "card");
// Expiry
formatInput("1225", "expiry");
// Date
formatInput("01012024", "date");
// PAN
formatInput("abcde1234f", "pan");
// Currency
formatInput("1000000", "currency");
// Detect
detectAndFormat("9876543210");🟦 TypeScript
import { formatInput, detectAndFormat } from "detect-format-input-type";
// Phone
formatInput("9876543210", "phone");
// Aadhaar
formatInput("123412341234", "aadhaar");
// Card
formatInput("1234567812345678", "card");
// Expiry
formatInput("1225", "expiry");
// Date
formatInput("01012024", "date");
// PAN
formatInput("abcde1234f", "pan");
// Currency
formatInput("1000000", "currency");
// Detect
detectAndFormat("ABCDE1234F");🔍 Auto Detect
detectAndFormat("ABCDE1234F");
// { type: "pan", formatted: "ABCDE1234F" }
detectAndFormat("9876543210");
// { type: "phone", formatted: "98765 43210" }🤝Contributing
Contributions are welcome! Feel free to open issues or submit pull requests on GitHub.
📄License
This project is licensed under the MIT License.
