Skip to content
项目

bguzmanrio/maskjs has 242 GitHub stars and 7 forks. GitHot measured 0 stars in 24 hours and 0 in 7 days. Last checked 2026-11-24 13:02 UTC. Last push 2016-02-03.

这些数字如何统计

可以做什么

  • Accepts any pattern order you would like to use
  • In case of dates, it will validates days out of range, and even leap years
  • You can use a custom function to handle the non validating inputs
  • It will write down any token automatically while you are typing.

实测星标增长

24小时
0
7天
0
15天
正在收集历史
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

关于

Mask.js is a simple functionality that you can use to force user met a pattern into inputs

开发工具

README.md

原文

Mask.js

What is Mask.js about?

Mask.js is a simple functionality that you can use to force user met a pattern into inputs

Dependencies?

Mask.js works on most jQuery versions.

Main Features

  • Accepts any pattern order you would like to use
  • In case of dates, it will validates days out of range, and even leap years
  • You can use a custom function to handle the non validating inputs
  • It will write down any token automatically while you are typing.
  • In erasing, tokens will be omitted, and while you are re-typing, them are going to ve pass over

How can I use Mask.js?

There are just a few steps:

  1. You have to import mark.js into your project

  2. Once imported, just pass the next parameter with you desired configuration:

    var options = {
      $el: jQuery input,
      mask: pattern to apply(described in the next section),
      errorFunction: callback function triggered on every error,
      defaultValue: defaultValue to be shown on initialization(applies on date format),
      hidePlaceholder: boolean for not showing the pattern placeholder,
      isUtc: if the pattern is a date format, utc will be considered
    }
    Mask.newMask(options);
    
  3. Pattern is the mask you want to apply over the input. It can be one of the following:

  • Any combination of YYYY-MM-DD HH:mm, where:
    • Y means year
    • M means month
    • D means day
    • H means hour
    • m means minutes
  • n for typing only numbers
  • az for typing only characters
  • az/n for typing both characters and numbers
  1. Additionaly you can add a number after n or az to limit the maximun characters users can write

Try it out

You can play around with it here: http://bguzmanrio.github.io/maskjs

探索相关项目

加载中…