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

validation-form-tool

v1.0.1

Published

该工具包,主要包含对常见表单输入框的格式验证以及文本替换

Readme

validation-form-tool

该工具包,主要包含对常见表单输入框的格式验证以及文本替换

Getting started

Installation

// npm
npm install validation-form-tool

// or yarn

yarn add validation-form-tool

Usage

import validator from 'validation-form-tool'
// 格式验证
validator.isMobile('18118761259') // true
validator.isMobile('1811876125') // false

// 文本替换
validator.onlyNumeric('123abc') // return 123

API

格式验证函数

  • isMobile 验证手机号格式(中国)
validator.isMobile('18118761259') // true
validator.isMobile('1811876125') // false
  • isTel 验证固定电话格式(中国)
validator.isTel('0755-88868187') // true
  • isEmail 验证邮箱格式,大部分常见邮箱都支持
validator.isEmail('[email protected]') // true
validator.isEmail('[email protected]') // true
  • isIdCard 验证身份证格式(中国),支持一代(15位)和二代(18位)
validator.isIdCard('xxxxxxxxxxxxxxx')
validator.isIdCard('xxxxxxxxxxxxxxxxxx')
  • isPassport 验证护照格式(中国),包含港澳
validator.isPassport('xxx')
validator.isPassport('xxx')
  • isWebsite 验证网址格式
validator.isWebsite('https://www.baidu.com') // true
validator.isWebsite('www.baidu.com') // true
  • isIncludeHTMLTags 验证是否包含html标签
validator.isIncludeHTMLTags('<a>include tag</a>') // true
validator.isIncludeHTMLTags('<>include tag<>') // false
  • isPostalCode 验证邮政编号(中国)
validator.isPostalCode('065001') // true
  • isLicensePlateNo 验证车牌号(中国)
validator.isLicensePlateNo('京A00001') // true
  • isIncludeChinese 验证是否包含中文字符
validator.isIncludeChinese('hello中国') // false
validator.isIncludeChinese('中国') // true

文本替换函数

  • onlyNumeric 只能输入数字
validator.onlyNumeric('123abc') // return 123
  • onlyCn 只能输入中文字符
validator.onlyCn('123abc你好') // return 你好
  • onlyLetters 只能输入字母
validator.onlyLetters('123abcABC') // return abcABC
  • onlyNumericAndLetters 只能输入数字和字母
validator.onlyNumericAndLetters('123abc你好') // return 123abc
  • onlyFloatingPoint 只能输入浮点数
validator.onlyFloatingPoint('123.34abc') // return 123.34
  • onlyCnAndNumericAndLetters 只能输入中文、数字、字母
validator.onlyCnAndNumericAndLetters('*&^123你好abc') // return 123你好abc