Browse Source

add masklevel casing

Robin Herbots 9 years ago
parent
commit
203efc4028
3 changed files with 10 additions and 3 deletions
  1. 1 0
      CHANGELOG.md
  2. 5 0
      README.md
  3. 4 3
      js/inputmask.js

+ 1 - 0
CHANGELOG.md

@@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
 ## [UNRELEASED]
 ## [UNRELEASED]
 
 
 ### Added
 ### Added
+- mask-level casing => #1352
 - 'casing': 'title' #1277
 - 'casing': 'title' #1277
 
 
 ### Updates
 ### Updates

+ 5 - 0
README.md

@@ -985,6 +985,11 @@ Default: true
 Positioning of the caret on click.  Options none, lvp (based on the last valid position (default), radixFocus (position caret to radixpoint on initial click)
 Positioning of the caret on click.  Options none, lvp (based on the last valid position (default), radixFocus (position caret to radixpoint on initial click)
 Default: "lvp"
 Default: "lvp"
 
 
+### casing
+Apply casing at the mask-level.
+Options: null, "upper", "lower" or "title"
+Default: null
+
 ## General
 ## General
 ### set a value and apply mask
 ### set a value and apply mask
 this can be done with the traditional jquery.val function (all browsers) or JavaScript value property for browsers which implement lookupGetter or getOwnPropertyDescriptor
 this can be done with the traditional jquery.val function (all browsers) or JavaScript value property for browsers which implement lookupGetter or getOwnPropertyDescriptor

+ 4 - 3
js/inputmask.js

@@ -118,7 +118,8 @@
 			jitMasking: false, //just in time masking ~ only mask while typing, can n (number), true or false
 			jitMasking: false, //just in time masking ~ only mask while typing, can n (number), true or false
 			nullable: true, //return nothing instead of the buffertemplate when the user hasn't entered anything.
 			nullable: true, //return nothing instead of the buffertemplate when the user hasn't entered anything.
 			inputEventOnly: false, //testing inputfallback behavior
 			inputEventOnly: false, //testing inputfallback behavior
-			positionCaretOnClick: "lvp" //none, lvp (based on the last valid position (default), radixFocus (position caret to radixpoint on initial click)
+			positionCaretOnClick: "lvp", //none, lvp (based on the last valid position (default), radixFocus (position caret to radixpoint on initial click)
+			casing: null //mask-level casing. Options: null, "upper", "lower" or "title"
 		},
 		},
 		masksCache: {},
 		masksCache: {},
 		mask: function (elems) {
 		mask: function (elems) {
@@ -1217,7 +1218,7 @@
 						if (tests[0].match.optionality !== true &&
 						if (tests[0].match.optionality !== true &&
 							tests[0].match.optionalQuantifier !== true &&
 							tests[0].match.optionalQuantifier !== true &&
 							tests[0].match.fn === null && !/[0-9a-bA-Z]/.test(tests[0].match.def)) {
 							tests[0].match.fn === null && !/[0-9a-bA-Z]/.test(tests[0].match.def)) {
-							return [determineTestTemplate(tests)]
+							return [determineTestTemplate(tests)];
 						}
 						}
 					}
 					}
 				}
 				}
@@ -1310,7 +1311,7 @@
 		}
 		}
 
 
 		function casing(elem, test, pos) {
 		function casing(elem, test, pos) {
-			switch (test.casing) {
+			switch (opts.casing || test.casing) {
 				case "upper":
 				case "upper":
 					elem = elem.toUpperCase();
 					elem = elem.toUpperCase();
 					break;
 					break;