1.0.4 • Published 2 years ago

phone-formatter-kyrgyz v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Phone formatter for kyrgyzstan phone numbers

Input that only allows numbers, and formats the input text to format as you type starting from "0".

0555555555 --> (0555) 55-55-55

Usage

yarn add phone-formatter-kyrgyz
npm install phone-formatter-kyrgyz
import { formatNumber } from "phone-formatter-kyrgyz";

const [input, setInput] = React.usestate<string>("");

const onChange = (e) => {
  const value = e.target.value;
  const result = formatNumber(value);

  setInput(result);
};

console.log(input);
// (0
// (05
// (055
// (0555)
// (0555) 5
// (0555) 55-
// (0555) 55-55-
// (0555) 55-55-55
<input onChange={onChange} value={input}> // 0555555555 -> (0555) 55-55-55