# Inputmask 3.x
Copyright (c) 2010 - 2017 Robin Herbots Licensed under the MIT license ([http://opensource.org/licenses/mit-license.php](http://opensource.org/licenses/mit-license.php))
[![NPM Version][npm-image]][npm-url] [![Dependency Status][david-image]][david-url] [![devDependency Status][david-dev-image]][david-dev-url]
Inputmask is a javascript library which creates an input mask. Inputmask can run against vanilla javascript, jQuery and jqlite.
An inputmask helps the user with the input by ensuring a predefined format. This can be useful for dates, numerics, phone numbers, ...
Highlights:
- easy to use
- optional parts anywere in the mask
- possibility to define aliases which hide complexity
- date / datetime masks
- numeric masks
- lots of callbacks
- non-greedy masks
- many features can be enabled/disabled/configured by options
- supports readonly/disabled/dir="rtl" attributes
- support data-inputmask attribute(s)
- alternator-mask
- regex-mask
- dynamic-mask
- preprocessing-mask
- JIT-masking
- value formatting / validating without input element
- AMD/CommonJS support
- dependencyLibs: vanilla javascript, jQuery, jqlite
- <strike>[Android support](README_android.md)</strike>
Demo page see [http://robinherbots.github.io/Inputmask](http://robinherbots.github.io/Inputmask)
[![donate](https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZNR3EB6JTMMSS)
## Setup
### dependencyLibs
Inputmask can run against different javascript libraries.
You can choose between:
- inputmask.dependencyLib (vanilla)
- inputmask.dependencyLib.jquery
- inputmask.dependencyLib.jqlite
- .... (others are welcome)
### Classic web with <script\> tag
Include the js-files which you can find in the `dist` folder.
If you want to include the Inputmask and all extensions. (with jQuery as dependencylib)
```html
<script src="jquery.js"></script>
<script src="dist/jquery.inputmask.bundle.js"></script>
<script src="dist/inputmask/phone-codes/phone.js"></script>
<script src="dist/inputmask/phone-codes/phone-be.js"></script>
<script src="dist/inputmask/phone-codes/phone-ru.js"></script>
```
For individual extensions. (with jQuery as dependencylib)
```html
<script src="jquery.js"></script>
<script src="dist/inputmask/inputmask.js"></script>
<script src="dist/inputmask/inputmask.extensions.js"></script>
<script src="dist/inputmask/inputmask.numeric.extensions.js"></script>
<script src="dist/inputmask/inputmask.date.extensions.js"></script>
<script src="dist/inputmask/inputmask.phone.extensions.js"></script>
<script src="dist/inputmask/jquery.inputmask.js"></script>
<script src="dist/inputmask/phone-codes/phone.js"></script>
<script src="dist/inputmask/phone-codes/phone-be.js"></script>
<script src="dist/inputmask/phone-codes/phone-ru.js"></script>
```
For individual extensions. (with vanilla dependencylib)
```html
<script src="dist/inputmask/dependencyLibs/inputmask.dependencyLib.js"></script>
<script src="dist/inputmask/inputmask.js"></script>
<script src="dist/inputmask/inputmask.extensions.js"></script>
<script src="dist/inputmask/inputmask.numeric.extensions.js"></script>
<script src="dist/inputmask/inputmask.date.extensions.js"></script>
<script src="dist/inputmask/inputmask.phone.extensions.js"></script>
<script src="dist/inputmask/phone-codes/phone.js"></script>
<script src="dist/inputmask/phone-codes/phone-be.js"></script>
<script src="dist/inputmask/phone-codes/phone-ru.js"></script>
```
If you like to automatically bind the inputmask to the inputs marked with the data-inputmask- ... attributes you may also want to include the inputmask.binding.js
```html
<script src="dist/inputmask/bindings/inputmask.binding.js"></script>
```
### webpack
#### Install the package
```
npm install inputmask --save-dev
```
#### In your modules
If you want to include the Inputmask and all extensions.
```
var Inputmask = require('inputmask');
//es6
import Inputmask from "inputmask";
```
For individual extensions.
Every extension exports the Inputmask, so you only need to import the extensions.
See example.
```
require("inputmask/dist/inputmask/inputmask.numeric.extensions");
var Inputmask = require("inputmask/dist/inputmask/inputmask.date.extensions");
//es6
import "inputmask/dist/inputmask/inputmask.numeric.extensions";
import Inputmask from "inputmask/dist/inputmask/inputmask.date.extensions";
```
#### Selecting the dependencyLib
By default the vanilla dependencyLib is used. You can select another dependency
by creating an alias in the webpack.config.
```
resolve: {
alias: {
"./dependencyLibs/inputmask.dependencyLib": "./dependencyLibs/inputmask.dependencyLib.jquery"
}
},
```
## Usage
### via Inputmask class
```javascript
var selector = document.getElementById("selector");
var im = new Inputmask("99-9999999");
im.mask(selector);
//or
Inputmask({"mask": "(999) 999-9999", .... other options .....}).mask(selector);
Inputmask("9-a{1,3}9{1,3}").mask(selector);
Inputmask("9", { repeat: 10 }).mask(selector);
```
### via jquery plugin
```javascript
$(document).ready(function(){
$(selector).inputmask("99-9999999"); //static mask
$(selector).inputmask({"mask": "(999) 999-9999"}); //specifying options
$(selector).inputmask("9-a{1,3}9{1,3}"); //mask with dynamic syntax
});
```
### via data-inputmask attribute
```html
<input data-inputmask="'alias': 'date'" />
<input data-inputmask="'mask': '9', 'repeat': 10, 'greedy' : false" />
<input data-inputmask="'mask': '99-9999999'" />
```
```javascript
$(document).ready(function(){
$(":input").inputmask();
or
Inputmask().mask(document.querySelectorAll("input"));
});
```
#### Any option can also be passed through the use of a data attribute. Use data-inputmask-<**_the name of the option_**>="value"
```html
<input id="example1" data-inputmask-clearmaskonlostfocus="false" />
<input id="example2" data-inputmask-regex="[a-za-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?" />
```
```javascript
$(document).ready(function(){
$("#example1").inputmask("99-9999999");
$("#example2").inputmask();
});
```
### Allowed HTML-elements
- `<input type="text">`
- `<input type="tel">`
- `<input type="password">`
- `<div contenteditable="true">` (and all others supported by contenteditable)
- `<textarea>`
- any html-element (mask text content or set maskedvalue with jQuery.val)
The allowed input types are defined in the supportsInputType option. Also see ([input-type-ref])
### Default masking definitions
- `9` : numeric
- `a` : alphabetical
- `*` : alphanumeric
There are more definitions defined within the extensions.<br>You can find info within the js-files or by further exploring the options.
## Masking types
### Static masks
These are the very basic of masking. The mask is defined and will not change during the input.
```javascript
$(document).ready(function(){
$(selector).inputmask("aa-9999"); //static mask
$(selector).inputmask({mask: "aa-9999"}); //static mask
});
```
### Optional masks
It is possible to define some parts in the mask as optional. This is done by using [ ].
Example:
```javascript
$('#test').inputmask('(99) 9999[9]-9999');
```
This mask wil allow input like `(99) 99999-9999` or `(99) 9999-9999`.
Input => 12123451234 mask => (12) 12345-1234 (trigger complete)<br>
Input => 121234-1234 mask => (12) 1234-1234 (trigger complete)<br>
Input => 1212341234 mask => (12) 12341-234_ (trigger incomplete)
#### skipOptionalPartCharacter
As an extra there is another configurable character which is used to skip an optional part in the mask.
```javascript
skipOptionalPartCharacter: " "
```
Input => 121234 1234 mask => (12) 1234-1234 (trigger complete)
When `clearMaskOnLostFocus: true` is set in the options (default), the mask will clear out the optiona
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
证件照制作微信小程序源码 支持付费制作等。多种流量主模式和支持微信公众号版本生成安 支持多种尺寸制作 支持相册上传于直接相机拍摄 支持多种类型的证件制作如,职业证件,公务员证件,身份证等各种类型 支持电子照存档等等 拥有小程序推荐功能,可以给其它的小程序实现引流 另外还支持换装美颜等功能! 支持多种流量主模式 支持付费制作等各种模式 支持多种模板替换 后台功能强大
资源推荐
资源详情
资源评论
收起资源包目录
证件照制作微信小程序源码 (2000个子文件)
uni-icons.acss 35KB
main.acss 15KB
select_bg.acss 5KB
mine-detail.acss 4KB
share.acss 4KB
index.acss 3KB
collect-search.acss 3KB
collect-list.acss 3KB
customSpecs.acss 3KB
collect-details.acss 3KB
changeBc.acss 3KB
uni-notice-bar.acss 3KB
diy-page.acss 2KB
print-order.acss 2KB
trees.acss 2KB
area-picker.acss 1KB
search.acss 1KB
orders.acss 1KB
zy-service.acss 1KB
print-orders.acss 1KB
collect-take.acss 1KB
mine.acss 1KB
c-print-submit.acss 1KB
service.acss 1KB
share-orders.acss 1KB
c-print-orders.acss 1KB
member.acss 945B
specs-detail.acss 911B
apply-share.acss 847B
c-print-index.acss 819B
receipt-info.acss 798B
pt-list.acss 787B
address.acss 783B
more.acss 775B
pt-detai.acss 767B
edit-address.acss 753B
share-ad.acss 736B
share-team.acss 719B
logistics.acss 667B
collect-creat.acss 611B
com-tabbar.acss 573B
collect-make.acss 549B
share-cash.acss 538B
creat-step.acss 485B
camera.acss 449B
collect-page.acss 382B
pt-page.acss 344B
cash-detail.acss 310B
apply-cash.acss 288B
login.acss 252B
jyf-parser.acss 100B
about-us.acss 79B
app.acss 31B
select_bg.axml 14KB
mine-detail.axml 10KB
index.axml 10KB
orders.axml 8KB
customSpecs.axml 7KB
diy-page.axml 6KB
trees.axml 5KB
changeBc.axml 5KB
print-order.axml 5KB
collect-list.axml 4KB
collect-take.axml 4KB
collect-search.axml 4KB
member.axml 4KB
print-orders.axml 3KB
collect-details.axml 3KB
share.axml 3KB
collect-creat.axml 3KB
specs-detail.axml 3KB
c-print-index.axml 3KB
uni-notice-bar.axml 2KB
pt-list.axml 2KB
search.axml 2KB
login.axml 2KB
zy-service.axml 2KB
address.axml 2KB
receipt-info.axml 2KB
apply-share.axml 2KB
mine.axml 2KB
camera.axml 2KB
edit-address.axml 2KB
collect-make.axml 2KB
cash-detail.axml 2KB
share-team.axml 2KB
service.axml 2KB
share-orders.axml 2KB
c-print-submit.axml 1KB
pt-detai.axml 1KB
com-tabbar.axml 1KB
collect-page.axml 1KB
area-picker.axml 1KB
c-print-orders.axml 1KB
share-cash.axml 1KB
logistics.axml 1KB
creat-step.axml 1KB
more.axml 1KB
pt-page.axml 899B
apply-cash.axml 816B
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
- qq_503143152024-04-07资源很实用,对我启发很大,有很好的参考价值,内容详细。
- python___12024-03-29资源内容详细全面,与描述一致,对我很有用,有一定的使用价值。
如鹿觅水
- 粉丝: 178
- 资源: 376
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- STM8L101F3P6单片机+CC1100模块433M遥控器设计硬件(原理图+PCB)工程文件.zip
- 上传下载铁人下载系统 Liuxing 1.0-liuxing1.0.rar
- 南京邮电大学数学实验实力雄厚,凭借其优秀的师资力量、丰富的实践教学资源和卓越的科研成果,成为国内一流的数学实验教学和科研基地
- 【火爆朋友圈的今天吃什么源码 v1.0】随机的为用户带来每一天的用餐选择和推荐.rar
- MPU6050中文版数据手册
- 上传下载手机电影下载-mobiledy.rar
- 响应式旅游网站源码下载 马尔代夫旅游网站.rar
- CMS小涴熊漫画连载系统漫画网站源码 带采集API.rar
- 福袋点点.apk
- 基于STM32的电子秤采用0.96寸OLED显示UI界面源码.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功