#jquery.inputmask 3.x
Copyright (c) 2010 - 2014 Robin Herbots
Licensed under the MIT license (http://opensource.org/licenses/mit-license.php)
[![devDependency Status](https://david-dm.org/RobinHerbots/jquery.inputmask/dev-status.svg)](https://david-dm.org/RobinHerbots/jquery.inputmask#info=devDependencies) [![peerDependency Status](https://david-dm.org/RobinHerbots/jquery.inputmask/peer-status.svg)](https://david-dm.org/RobinHerbots/jquery.inputmask#info=peerDependencies)
jquery.inputmask is a jQuery plugin which create an input mask.
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 support
- regex-mask support
- dynamic-mask support
- preprocessing-mask support
- value formatting / validating without input element
- AMD support
Demo page see http://robinherbots.github.io/jquery.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)
## Usage:
Include the js-files which you can find in the dist-folder. You have the bundled file which contains the main plugin code and also all extensions (date, numerics, other) or if you prefer to only include some parts, use the separate js-files in the dist/min folder.
If you use a module loader like requireJS, use the js-files in dist/inputmask
The minimum to include is the jquery.inputmask.js
```html
<script src="jquery.js" type="text/javascript"></script>
<script src="jquery.inputmask.js" type="text/javascript"></script>
```
Define your masks:
```javascript
$(document).ready(function(){
$(selector).inputmask("99-9999999"); //static mask
$(selector).inputmask("mask", {"mask": "(999) 999-9999"}); //specifying fn & options
$(selector).inputmask({"mask": "99-9999999"}); //specifying options only
$(selector).inputmask("9-a{1,3}9{1,3}"); //mask with dynamic syntax
});
```
or 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();
});
```
Any option can also be passed through the use of a data attribute. Use data-inputmask-<***the name op 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("Regex");
});
```
#### Default masking definitions
- 9 : numeric
- a : alphabetical
- * : alphanumeric
There are more definitions defined within the extensions.
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)
Input => 121234-1234 mask => (12) 1234-1234 (trigger complete)
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 optional part when it is not filled in and this only in case the optional part is at the end of the mask.
For example, given:
```javascript
$('#test').inputmask('999[-AAA]');
```
While the field has focus and is blank, users will see the full mask `___-___`.
When the required part of the mask is filled and the field loses focus, the user will see `123`.
When both the required and optional parts of the mask are filled out and the field loses focus, the user will see `123-ABC`.
#### Optional masks with greedy false
When defining an optional mask together with the greedy: false option, the inputmask will show the smallest possible mask as input first.
```javascript
$(selector).inputmask({ mask: "99999[-9999]", greedy: false });
```
The initial mask shown will be "_____" instead of "_____-____".
### Dynamic masks
Dynamic masks can change during the input. To define a dynamic part use { }.
{n} => n repeats
{n,m} => from n to m repeats
Also {+} and {*} is allowed. + start from 1 and * start from 0.
```javascript
$(document).ready(function(){
$(selector).inputmask("aa-9{4}"); //static mask with dynamic syntax
$(selector).inputmask("aa-9{1,4}"); //dynamic mask ~ the 9 def can be occur 1 to 4 times
//email mask
$(selector).inputmask({
mask: "*{1,20}[.*{1,20}][.*{1,20}][.*{1,20}]@*{1,20}[.*{2,6}][.*{1,2}]",
greedy: false,
onBeforePaste: function (pastedValue, opts) {
pastedValue = pastedValue.toLowerCase();
return pastedValue.replace("mailto:", "");
},
definitions: {
'*': {
validator: "[0-9A-Za-z!#$%&'*+/=?^_`{|}~\-]",
cardinality: 1,
casing: "lower"
}
}
});
```
### Alternator masks
The alternator syntax is like an **OR** statement. The mask can be one of the 2 choices specified in the alternator.
To define an alternator use the |.
ex: "a|9" => a or 9
"(aaa)|(999)" => aaa or 999
Also make sure to read about the keepStatic option.
```javascript
$("selector").inputmask("(99.9)|(X)", {
definitions: {
"X": {
validator: "[xX]",
cardinality: 1,
casing: "upper"
}
}
});
```
or
```javascript
$("selector").inputmask({
mask: ["99.9", "X"],
definitions: {
"X": {
validator: "[xX]",
cardinality: 1,
casing: "upper"
}
}
});
```
### Preprocessing masks
You can define the mask as a function which can allow to preprocess the resulting mask. Example sorting for multiple masks or retrieving mask definitions dynamically through ajax.
The preprocessing fn should return a valid mask definition.
```javascript
$(selector).inputmask({ mask: function () { /* do stuff */ return ["[1-]AAA-999", "[1-]999-AAA"]; }});
```
## Define custom definitions
You can define your own definitions to use in your mask.
Start by choosing a masksymbol.
##### validator(chrs, maskset, pos, strict, opts)
Next define your validator. The validator can be a regular expression or a function.
The return value of a validator can be true, false or a command object.
###### Options of the command object
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【资源说明】 基于Python+Flask的工时统计系统源码+部署文档+全部数据资料 高分项目.zip基于Python+Flask的工时统计系统源码+部署文档+全部数据资料 高分项目.zip 【备注】 1、该项目是个人高分项目源码,已获导师指导认可通过,答辩评审分达到95分 2、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 3、本项目适合计算机相关专业(人工智能、通信工程、自动化、电子信息、物联网等)的在校学生、老师或者企业员工下载使用,也可作为毕业设计、课程设计、作业、项目初期立项演示等,当然也适合小白学习进阶。 4、如果基础还行,可以在此代码基础上进行修改,以实现其他功能,也可直接用于毕设、课设、作业等。 欢迎下载,沟通交流,互相学习,共同进步!
资源推荐
资源详情
资源评论
收起资源包目录
基于Python+Flask的工时统计系统源码+部署文档+全部数据资料 高分项目.zip (2000个子文件)
bootstrap.css 144KB
bootstrap.min.css 120KB
bootstrapTheme.css 120KB
main.css 120KB
jquery.minicolors.css 106KB
settings.css 72KB
editor_ie7.css 48KB
editor_iequirks.css 47KB
editor_ie8.css 46KB
editor_ie.css 46KB
editor_gecko.css 45KB
editor.css 45KB
bootstrap-datepicker3.standalone.css 33KB
bootstrap-datepicker3.css 32KB
bootstrap-datepicker3.standalone.min.css 31KB
bootstrap-datepicker3.min.css 31KB
jquery-ui.min.css 29KB
jquery.treetable.theme.default.css 29KB
font-awesome.css 28KB
extralayers.css 27KB
font-awesome.css 26KB
settings-ie8.css 26KB
font-awesome.min.css 23KB
custom.css 21KB
responsive.css 21KB
bootstrap-editable.css 21KB
_all.css 20KB
select2.css 18KB
bootstrap-datepicker.standalone.css 18KB
dialog_ie7.css 17KB
jquery.dataTables.css 17KB
bootstrap-datepicker.css 17KB
dialog_ie8.css 17KB
dialog_iequirks.css 16KB
mapplic.css 16KB
dialog_ie.css 16KB
bootstrap-datepicker.standalone.min.css 16KB
dialog.css 16KB
layerslider.css 15KB
bootstrap-datepicker.min.css 15KB
jquery.dataTables.min.css 15KB
_all.css 14KB
_all.css 14KB
_all.css 12KB
bootstrap-datetimepicker.css 12KB
export.css 12KB
jquery.dataTables_themeroller.css 12KB
dataTables.jqueryui.css 11KB
dropzone.css 11KB
simple-line-icons.css 11KB
uniform.default.css 11KB
jquery.dataTables_themeroller.min.css 10KB
summernote.css 10KB
shCore.css 10KB
dataTables.tableTools.css 9KB
simple-line-icons.min.css 9KB
normalize.css 9KB
bootstrap-datetimepicker.min.css 9KB
shCoreDefault.css 9KB
uniform.default.min.css 8KB
toastr.css 7KB
bootstrap-switch.css 7KB
blueimp-gallery.min.css 7KB
noneed.css 7KB
bootstrap-select.css 7KB
bootstrap-switch.min.css 6KB
bootstrap-gtreetable.css 6KB
jquery.ui.plupload.css 6KB
shCore.css 6KB
custom.css 6KB
demo.css 6KB
bootstrap-gtreetable.min.css 6KB
clockface.css 6KB
dataTables.colVis.css 6KB
dataTables.tableTools.min.css 6KB
bootstrap-select.min.css 6KB
daterangepicker-bs3.css 6KB
toastr.min.css 5KB
daterangepicker-bs2.css 5KB
dataTables.bootstrap.css 5KB
style.css 5KB
sample.css 5KB
jquery.notific8.min.css 5KB
dataTables.foundation.css 5KB
skin.css 4KB
owl.transitions.css 4KB
skin.css 4KB
dataTables.bootstrap.css 4KB
dataTables.colVis.min.css 4KB
bootstrap-modal.css 4KB
skin.css 4KB
skin.css 4KB
skin.css 4KB
skin.css 4KB
jquery.fancybox.css 4KB
skin.css 4KB
skin.css 4KB
jquery.plupload.queue.css 4KB
basic.css 4KB
skin.css 4KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
不走小道
- 粉丝: 3225
- 资源: 5113
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- vmware workstation pro 17 linux版
- 3479521_1710042575-1.rwmod
- 安装及环境配置UMCM-2023C-ma笔记
- (完整)数据库课程设计餐厅点餐说明书-21ab6d3c8beb172ded630b1c59eef8c75ebf952c.doc
- 2023-04-06-项目笔记 - 第一百五十四阶段 - 4.4.2.152全局变量的作用域-152 -2024.06.04
- 松哥解协议松哥解协议松哥解协议松哥解协议松哥解协议
- 618节日618节日618节日
- tensorflow-gpu-2.9.1-cp37-cp37m-win-amd64.whl
- tensorflow-gpu-2.9.0-cp37-cp37m-win-amd64.whl
- tensorflow-gpu-2.9.0-cp39-cp39-win-amd64.whl
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功