Inputmask
文件大小: unknow
源码售价: 5 个金币 积分规则     积分充值
资源说明:Input Mask plugin
# Inputmask

Copyright (c) 2010 - 2021 Robin Herbots Licensed under the MIT license ()

The Inputmask has a very permissive license and this will stay that way.  But when you use the Inputmask in a commercial setting, be so honest to make a small donation.
This will be appreciated very much.

[![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)
  
![npm](https://img.shields.io/npm/v/inputmask) ![npm (tag)](https://img.shields.io/npm/v/inputmask/next) ![Libraries.io dependency status for latest release](https://img.shields.io/librariesio/release/npm/inputmask)

Inputmask is a javascript library that 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 anywhere in the mask
- possibility to define aliases which hide the complexity
- date / DateTime masks
- numeric masks
- lots of callbacks
- non-greedy masks
- many features can be enabled/disabled/configured by options
- supports read-only/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
- \ htmlelement

Demo page see 

Thanks to [Jetbrains](https://www.jetbrains.com/?from=inputmask) for providing a free license for their excellent Webstorm IDE.  

  Jetbrains

    
Thanks to [Browserstack](https://www.browserstack.com) for providing a free license, so we can automate testing in different browsers and devices.  

  Browserstack



## Setup
### dependencyLibs
Inputmask can run against different javascript libraries.
You can choose between:
- inputmask.dependencyLib (vanilla)
- inputmask.dependencyLib.jquery

### Classic web with  tag
Include the js-files which you can find in the `dist` folder.

Inputmask with jQuery as dependencylib.
```html


```

Inputmask with vanilla dependencylib.
```html

```

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

```

### webpack

#### Install the package
```
npm install inputmask --save
```

##### Install the latest beta version
```
npm install inputmask@next --save
```

#### In your modules
If you want to include the Inputmask and all extensions.
```
var Inputmask = require('inputmask');

//es6
import Inputmask from "inputmask";
```

### ES6
```
import Inputmask from "inputmask.es6.js";
```

## 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);

Inputmask({ regex: "\\d*" }).mask(selector);
Inputmask({ regex: String.raw`\d*` }).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



```

```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


```

```javascript
$(document).ready(function(){
  $("#example1").inputmask("99-9999999");
  $("#example2").inputmask();
});
```

### via \ element
Use the input-mask element in your HTML code and set the options as attributes.

```html

```


### Allowed HTML-elements
- ``
- ``
- ``
- ``
- ``
- `
` (and all others supported by contenteditable) - `