New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-input-auto-format

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-input-auto-format

A super simple input component that formats as you type.

latest
Source
npmnpm
Version
1.0.7
Version published
Weekly downloads
7
-61.11%
Maintainers
1
Weekly downloads
 
Created
Source

react-input-auto-format

React Input Auto Format (catchy, I know) automatically formats the value of an input field while you're typing in it.

<Input format="## - ## - ##">

Formatted input

Quickstart

Install it:

npm install react-input-auto-format

Have fun:

import Input from 'react-input-auto-format';

function Foo () {
    return <Input format="## - ## - ##" />;
}

The format prop accepts a pattern. The # character represents any number or letter, and you can put whatever else you like in there.

Examples:

StylePatternResult
Expiry date## / ##12 / 34
Sort code## - ## - ##12 - 34 - 56
Number plate#### ###LM68 XKC

Getting the raw value

To get the unformatted value, use the onValueChange prop.

function Foo () {
    handleValueChange(value) {
        console.log(value); // 123456
    }

    return <Input
        format="## - ## - ##"
        onValueChange={handleValueChange}
    />;
}

Everything else

All other props work the same as you would expect for a native input component. If you want the formatted value, use a standard onChange attribute and pull out event.target.value.

Keywords

react

FAQs

Package last updated on 14 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts