0.2.1 • Published 3 years ago

creditcard-input-react v0.2.1

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

creditcard-input-react

✨ A simple and straightforward react creditcard input component.

Feature

  • Auto add space every 4 digits
  • Remove inputs other than numbers
  • Easy to customize to your own (cuz it's unstyled)

Install

npm i creditcard-input-react

Usage

👉 ccNumber : credit card number

import { CcNumberInput } from 'creditcard-input-react'

const App = () => {
    return (
        <main>
            <CcNumberInput
                className='creditcard-number-input'
                placeholder='e.g 1234 1234 1234 1234'
                onCcNumberChange={(ccNumber) => console.log(ccNumber)}
            />
        </main>
    )
}

you can also store the ccNumber into your own state

import { useState } from 'react'
import { CcNumberInput } from 'creditcard-input-react'

const App = () => {
    const [ccNumber, setCcNumber] = useState('')

    return (
        <main>
            <CcNumberInput
                onCcNumberChange={(newCcNumber) => setCcNumber(newCcNumber)}
            />
            <div>{ccNumber}</div>
        </main>
    )
}

Licence

MIT

0.2.1

3 years ago

0.2.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.0.10

3 years ago

0.1.0

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago

0.0.0

3 years ago