1.1.1 • Published 4 years ago

number-form v1.1.1

Weekly downloads
81
License
MIT
Repository
github
Last release
4 years ago

Number Form

An easy way to format your numbers

Install

npm i number-form

Import

import { numberForm } from 'number-form';

Usage

var formattedValue = numberForm(originalValue, template, event);
Where 'template' is a string that represents the format you would like your numbers to form to.

Example of commonly used templates

Phone numbers: '(xxx)xxx-xxxx'
Credit cards: 'xxxx-xxxx-xxxx-xxxx'
Dates: 'xx/xx/xxxx'
Where your x's will be replaced by the user's input.

Example usage in Vue.js

<template>
  <input type="text" v-model="phone" @keyup="formatPhone" />
</template>
<script>
  import { numberForm } from 'number-form'

  export default {
    data() {
      return {
        phone: ''
      }
    },
    methods: {
      formatPhone(event) {
        this.phone = numberForm(this.phone, 'xxx-xxx-xxxx', event)
      }
    }
  }
</script>
1.1.1

4 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago