npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vue-pattern-input

v3.0.0

Published

A Vue Component for limiting user input

Readme

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

  • Support Vue3.0

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.