All Projects → RoamIn → vue-pattern-input

RoamIn / vue-pattern-input

Licence: MIT license
Use RegExp to limit input

Programming Languages

Vue
7211 projects

Projects that are alternatives of or similar to vue-pattern-input

vue-snippets
Visual Studio Code Syntax Highlighting For Vue3 And Vue2
Stars: ✭ 25 (+0%)
Mutual labels:  vue2, vue3, vuejs3
vue-list-picker
Just a simple list picker component made with Vue.js (works with Vue 2 & 3)
Stars: ✭ 14 (-44%)
Mutual labels:  vue-component, vue3
vue-virtualised
Blazing fast scrolling and updating for any amount of list and hierarchical data.
Stars: ✭ 18 (-28%)
Mutual labels:  vue-component, vue3
vue-insta-stories
Vue 2 & 3 library for Instagram like stories.
Stars: ✭ 45 (+80%)
Mutual labels:  vue2, vue3
Vue Trix
Trix text editor component for Vue.js
Stars: ✭ 159 (+536%)
Mutual labels:  vue2, vue-component
Vue Marquee Text Component
[CSS GPU Animation] Marquee Text for vuejs
Stars: ✭ 226 (+804%)
Mutual labels:  vue2, vue-component
vue-input-autowidth
A Vue.js directive that automatically resizes an input's width to fit its contents.
Stars: ✭ 94 (+276%)
Mutual labels:  vue2, vue3
Vue Truncate Collapsed
A simple component that truncates your text and adds a 'Read More/Show Less' clickable.
Stars: ✭ 98 (+292%)
Mutual labels:  vue2, vue-component
vue-collapse
A simple collapse component for Vue.js
Stars: ✭ 34 (+36%)
Mutual labels:  vue2, vue-component
lightvue
The Emerging UI Component library designed for Vue 3.x & Vue 2.x
Stars: ✭ 78 (+212%)
Mutual labels:  vue3, vuejs3
vue3-table-lite
A simple and lightweight data table component for Vue.js 3. Features sorting, paging, row check, dynamic data rendering, supported TypeScript, and more.
Stars: ✭ 148 (+492%)
Mutual labels:  vue3, vuejs3
Vue Codemirror
⌨️ @codemirror component for @vuejs
Stars: ✭ 2,115 (+8360%)
Mutual labels:  vue2, vue-component
Vue Awesome Swiper
🏆 Swiper component for @vuejs
Stars: ✭ 12,072 (+48188%)
Mutual labels:  vue2, vue-component
Vue Form Json Schema
Create forms using JSON schema. Bring your components!
Stars: ✭ 253 (+912%)
Mutual labels:  vue2, vue-component
Vue Online
A reactive offline indicator component for vue.js
Stars: ✭ 130 (+420%)
Mutual labels:  vue2, vue-component
vue-ray
Debug your Vue 2 & 3 code with Ray to fix problems faster
Stars: ✭ 48 (+92%)
Mutual labels:  vue2, vue3
vue-universal-modal
Universal modal plugin for Vue3
Stars: ✭ 57 (+128%)
Mutual labels:  vue3, vuejs3
Xcui
🍴 A Vue.js 2.x desktop components colletion
Stars: ✭ 88 (+252%)
Mutual labels:  vue2, vue-component
Vue Toastr
Vuejs Toast : Plugin and Component Capability.
Stars: ✭ 93 (+272%)
Mutual labels:  vue2, vue-component
vuejs-3-examples
Some examples of Vue.js 3.0.
Stars: ✭ 26 (+4%)
Mutual labels:  vue3, vuejs3

vue-pattern-input

npm package NPM downloads

A Vue Component used RegExp to limit the user's input.

Works like native input element, you can add maxlength class attributes. You can use v-model too.

English | 简体中文

Table of contents

Live demo

Just click there: Live Demo.

What's included

Within the download you'll find the following directories and files, logically grouping common assets and providing both compiled and minified variations. You'll see something like this:

vue-pattern-input/
├── ...
├── src/
│   └── /component
│       └── pattern-input.vue // core
└── /view
    └── demo.html

Parameter declaration

Parameter Type Default Required Description
regExp RegExp null false Using for: String.prototype.replace(regexp, replacement)
replacement String '' false Using for: String.prototype.replace(regexp, replacement)
v-model[.number] String/Number true Using for getting input value

Commonly used regExp

regExp Description
/^[0\D]*|\D*/g positive integer
/[^a-z]/g lowercase
/[^A-Z]/g uppercase
/[^\w]/g \w, Equivalent to [A-Za-z0-9_]
/[^\u4e00-\u9fa5]/g Chinese

Quick start

JavaScript

setting: {
  regExp: /^[0\D]*|\D*/g, // Match any character that doesn't belong to the positive integer
  replacement: '',
  val: '223'
}

HTML

<pattern-input class="your-class-name"
               :regExp="setting.regExp"
               :replacement="setting.replacement"
               @input="handleInput"
               @change="handleChange"
               v-model.number="setting.val"></pattern-input>

This setting will make user input positive integer only.

When you want get a Number, remember use v-model.number, and the safe maxlength is 15.

Changelog

v3.0.0

  • v3.0.0 provides Vue 3 support. You can still use v2.x for Vue 2.

v2.1.4

  • Use immediate watch

v2.1.3

  • I'm not sure is it necessary to emit all the input events. Now I only emit input and change events.
  • Now, you can bind any native event on input !
    <pattern-input
                   ...
                   @change="onChange"
                   @blur="onBlur"
                   @focus="onFocus"
                   ...etc
                   ...</pattern-input>
  • Required:

Bugs and feature requests

Have a bug or a feature request? If your problem or idea is not addressed yet, please open a new issue.

Thought

I'm not sure is it necessary to emit all the input events. Now I only emit input and change events.

And I think the RegExp settings is not good enough, it's a bit awkward. Maybe I should match what I want instead of replacing what I don't want. But how ?

License

Code released under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].