|
|
@@ -5,54 +5,6 @@ jquery.inputmask is a jquery plugin which create an input mask.
|
|
|
Copyright (c) 2010 - 2013 Robin Herbots
|
|
|
Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
|
|
|
|
|
|
-The plugin is based on the idea of the maskedinput plugin of Josh Bush (http://digitalbush.com/projects/masked-input-plugin), but has finer control over the 'mask-definitions'.
|
|
|
-
|
|
|
-A definition can have a cardinality and have multiple prevalidators.
|
|
|
-
|
|
|
-Example of some new definitions:
|
|
|
-
|
|
|
-```javascript
|
|
|
- 'm': { //month
|
|
|
- validator: function(chrs, buffer) {
|
|
|
- var dayValue = buffer.join('').substr(0, 3);
|
|
|
- return $.inputmask.defaults.aliases['dd/mm/yyyy'].regex.month.test(dayValue + chrs);
|
|
|
- },
|
|
|
- cardinality: 2,
|
|
|
- prevalidator: [{ validator: "[01]", cardinality: 1}]
|
|
|
- },
|
|
|
- 'y': { //year
|
|
|
- validator: function(chrs, buffer) {
|
|
|
- if ($.inputmask.defaults.aliases['dd/mm/yyyy'].regex.year.test(chrs)) {
|
|
|
- var dayMonthValue = buffer.join('').substr(0, 6);
|
|
|
- if (dayMonthValue != "29/02/")
|
|
|
- return true;
|
|
|
- else {
|
|
|
- var year = parseInt(chrs); //detect leap year
|
|
|
- if (year % 4 == 0)
|
|
|
- if (year % 100 == 0)
|
|
|
- if (year % 400 == 0)
|
|
|
- return true;
|
|
|
- else return false;
|
|
|
- else return true;
|
|
|
- else return false;
|
|
|
- }
|
|
|
- } else return false;
|
|
|
- },
|
|
|
- cardinality: 4,
|
|
|
- prevalidator: [
|
|
|
- { validator: "[12]", cardinality: 1 },
|
|
|
- { validator: "(19|20)", cardinality: 2 },
|
|
|
- { validator: "(19|20)\\d", cardinality: 3 }
|
|
|
- ]
|
|
|
- }
|
|
|
-},
|
|
|
-insertMode: false
|
|
|
-```
|
|
|
-
|
|
|
-These allow for a finer date validation then 99/99/9999 which also allows 33/33/3333 for example.
|
|
|
-In the jquery.inputmask.extensions.js you find a full date input validation which takes days, months & leap years into account.
|
|
|
-
|
|
|
-Also extra features like mask-repetitions (greedy and non-gready) and many other additions are included. In the examples you will find more about them.
|
|
|
|
|
|
|
|
|
## Usage:
|