|
|
@@ -5,7 +5,6 @@ The plugin is based on the maskedinput plugin of Josh Bush (http://digitalbush.c
|
|
|
A definition can have a cardinality and have multiple prevalidators.
|
|
|
|
|
|
Example of some new definitions:
|
|
|
-
|
|
|
```javascript
|
|
|
'm': { //month
|
|
|
validator: function(chrs, buffer) {
|
|
|
@@ -53,13 +52,13 @@ Also extra features like mask-repetitions (greedy and non-gready) and many other
|
|
|
Usage:
|
|
|
|
|
|
Include the js-files:
|
|
|
-
|
|
|
+```html
|
|
|
<script src="jquery.js" type="text/javascript"></script>
|
|
|
<script src="jquery.inputmask.js" type="text/javascript"></script>
|
|
|
<script src="jquery.inputmask.extentions.js" type="text/javascript"></script>
|
|
|
+```
|
|
|
|
|
|
Define your masks:
|
|
|
-
|
|
|
```javascript
|
|
|
$(document).ready(function(){
|
|
|
$("#date").inputmask("d/m/y"); //direct mask
|
|
|
@@ -79,7 +78,6 @@ $(document).ready(function(){
|
|
|
```
|
|
|
|
|
|
or a multi-char placeholder
|
|
|
-
|
|
|
```javascript
|
|
|
$(document).ready(function(){
|
|
|
$("#date").inputmask("d/m/y",{ "placeholder": "dd/mm/yyyy" });
|
|
|
@@ -87,7 +85,6 @@ $(document).ready(function(){
|
|
|
```
|
|
|
|
|
|
### execute a function when the mask is completed, incomplete or cleared
|
|
|
-
|
|
|
```javascript
|
|
|
$(document).ready(function(){
|
|
|
$("#date").inputmask("d/m/y",{ "oncomplete": function(){ alert('inputmask complete'); } });
|
|
|
@@ -97,7 +94,6 @@ $(document).ready(function(){
|
|
|
```
|
|
|
|
|
|
### mask repeat function
|
|
|
-
|
|
|
```javascript
|
|
|
$(document).ready(function(){
|
|
|
$("#number").inputmask({ "mask": "9", "repeat": 10 }); // ~ mask "9999999999"
|
|
|
@@ -105,7 +101,6 @@ $(document).ready(function(){
|
|
|
```
|
|
|
|
|
|
### mask non-greedy repeat function
|
|
|
-
|
|
|
```javascript
|
|
|
$(document).ready(function(){
|
|
|
$("#number").inputmask({ "mask": "9", "repeat": 10, "greedy": false }); // ~ mask "9" or mask "99" or ... mask "9999999999"
|
|
|
@@ -113,7 +108,6 @@ $(document).ready(function(){
|
|
|
```
|
|
|
|
|
|
### get the unmaskedvalue
|
|
|
-
|
|
|
```javascript
|
|
|
$(document).ready(function(){
|
|
|
$("#number").inputmask('unmaskedvalue');
|
|
|
@@ -121,7 +115,6 @@ $(document).ready(function(){
|
|
|
```
|
|
|
|
|
|
### set a value and apply mask
|
|
|
-
|
|
|
```javascript
|
|
|
$(document).ready(function(){
|
|
|
$("#number").inputmask('setvalue', 12345);
|
|
|
@@ -129,7 +122,6 @@ $(document).ready(function(){
|
|
|
```
|
|
|
|
|
|
when the option patch_eval is set to true the same can be done with the traditionnal jquery.val function
|
|
|
-
|
|
|
```javascript
|
|
|
$(document).ready(function(){
|
|
|
$("#number").val(12345);
|
|
|
@@ -137,7 +129,6 @@ $(document).ready(function(){
|
|
|
```
|
|
|
|
|
|
with the autoUnmaskoption you can change the return of $.fn.val to unmaskedvalue or the maskedvalue
|
|
|
-
|
|
|
```javascript
|
|
|
$(document).ready(function(){
|
|
|
$('#<%= tbDate.ClientID%>').inputmask({ "mask": "d/m/y", 'autoUnmask' : true}); // value: 23/03/1973
|
|
|
@@ -147,7 +138,6 @@ $(document).ready(function(){
|
|
|
```
|
|
|
|
|
|
### add custom definitions
|
|
|
-
|
|
|
```javascript
|
|
|
$.extend($.inputmask.defaults.definitions, {
|
|
|
'f': {
|
|
|
@@ -159,7 +149,6 @@ $.extend($.inputmask.defaults.definitions, {
|
|
|
```
|
|
|
|
|
|
### set defaults
|
|
|
-
|
|
|
```javascript
|
|
|
$.extend($.inputmask.defaults, {
|
|
|
'autounmask': true
|
|
|
@@ -167,7 +156,6 @@ $.extend($.inputmask.defaults, {
|
|
|
```
|
|
|
|
|
|
### numeric input direction
|
|
|
-
|
|
|
```javascript
|
|
|
$(document).ready(function(){
|
|
|
$('#test').inputmask('€ 999.999.999,99', { numericInput: true }); // 123456 => € ___.__1.234,56
|
|
|
@@ -175,7 +163,6 @@ $(document).ready(function(){
|
|
|
```
|
|
|
|
|
|
### remove the inputmask
|
|
|
-
|
|
|
```javascript
|
|
|
$(document).ready(function(){
|
|
|
$('#test').inputmask('remove');
|
|
|
@@ -183,7 +170,6 @@ $(document).ready(function(){
|
|
|
```
|
|
|
|
|
|
### escape special mask chars
|
|
|
-
|
|
|
```javascript
|
|
|
$(document).ready(function(){
|
|
|
$("#months").inputmask("m \\months");
|
|
|
@@ -191,7 +177,6 @@ $(document).ready(function(){
|
|
|
```
|
|
|
|
|
|
### clearIncomplete - remove incomplete input on blur
|
|
|
-
|
|
|
```javascript
|
|
|
$(document).ready(function(){
|
|
|
$("#ssn").inputmask("999-99-9999",{placeholder:" ", clearIncomplete: true });
|
|
|
@@ -202,7 +187,6 @@ $(document).ready(function(){
|
|
|
When `clearIncomplete: true` is set in the options, the mask will treat masks marked option as separate from those that are not optional.
|
|
|
|
|
|
For example, given:
|
|
|
-
|
|
|
```javascript
|
|
|
$('#test').inputmask('999[-AAA]',{
|
|
|
clearIncomplete: true
|
|
|
@@ -213,7 +197,6 @@ When the required part of the mask is filled and the field loses focus, the user
|
|
|
When both the required and optional parts of the mask are filled out and the field loses focus, the user will see `123-abc`.
|
|
|
|
|
|
### oncleared option
|
|
|
-
|
|
|
```javascript
|
|
|
$(document).ready(function(){
|
|
|
$("#ssn").inputmask("999-99-9999",{placeholder:" ", oncleared: function(){ alert('Set focus somewhere else ;-)');} });
|
|
|
@@ -223,7 +206,6 @@ $(document).ready(function(){
|
|
|
### aliases option
|
|
|
|
|
|
First you have to create an alias definition (more examples can be found in jquery.inputmask.extentions.js)
|
|
|
-
|
|
|
```javascript
|
|
|
$.extend($.inputmask.defaults.aliases, {
|
|
|
'date': {
|
|
|
@@ -236,7 +218,6 @@ $.extend($.inputmask.defaults.aliases, {
|
|
|
```
|
|
|
|
|
|
use:
|
|
|
-
|
|
|
```javascript
|
|
|
$(document).ready(function(){
|
|
|
$("#date").inputmask("date"); => equals to $("#date").inputmask("d/m/y");
|
|
|
@@ -244,7 +225,6 @@ $(document).ready(function(){
|
|
|
```
|
|
|
|
|
|
or use the dd/mm/yyyy alias of the date alias:
|
|
|
-
|
|
|
```javascript
|
|
|
$(document).ready(function(){
|
|
|
$("#date").inputmask("dd/mm/yyyy"); => equals to $("#date").inputmask("d/m/y");
|
|
|
@@ -255,7 +235,6 @@ $(document).ready(function(){
|
|
|
|
|
|
see jquery.inputmask.extentions.js for an example how to define "auto"-casing in a definition (definition A)
|
|
|
casing can be null, "upper" or "lower"
|
|
|
-
|
|
|
```javascript
|
|
|
$(document).ready(function(){
|
|
|
$("#test").inputmask("999-AAA"); => 123abc ===> 123-ABC
|
|
|
@@ -265,7 +244,6 @@ $(document).ready(function(){
|
|
|
### getemptymask command
|
|
|
|
|
|
return the default (empty) mask value
|
|
|
-
|
|
|
```javascript
|
|
|
$(document).ready(function(){
|
|
|
$("#test").inputmask("999-AAA");
|
|
|
@@ -276,7 +254,9 @@ $(document).ready(function(){
|
|
|
### RTL input
|
|
|
|
|
|
Just add the dir="rtl" attribute to the input element
|
|
|
+```html
|
|
|
<input id="test" dir="rtl" />
|
|
|
+```
|
|
|
|
|
|
-----------------------------------------
|
|
|
|