Browse Source

added autoCasing option - see the readme for usage

Robin Herbots 14 years ago
parent
commit
a47a005053
2 changed files with 16 additions and 4 deletions
  1. 2 2
      README
  2. 14 2
      jquery.inputmask.js

+ 2 - 2
README

@@ -195,5 +195,5 @@ $(document).ready(function(){
 auto uppercasing inputmask
 auto uppercasing inputmask
 
 
 $(document).ready(function(){
 $(document).ready(function(){
-  todo
-});
+   $("#test").inputmask("999-aaa", { autoCasing: "upper" });       => 123abc ===> 123-ABC 
+});

+ 14 - 2
jquery.inputmask.js

@@ -3,7 +3,7 @@ Input Mask plugin for jquery
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 Robin Herbots
 Copyright (c) 2010 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 0.4.5g
+Version: 0.4.6
  
  
 This plugin is based on the masked input plugin written by Josh Bush (digitalbush.com)
 This plugin is based on the masked input plugin written by Josh Bush (digitalbush.com)
 */
 */
@@ -30,6 +30,7 @@ This plugin is based on the masked input plugin written by Josh Bush (digitalbus
                 clearMaskOnLostFocus: true,
                 clearMaskOnLostFocus: true,
                 insertMode: true, //insert the input or overwrite the input
                 insertMode: true, //insert the input or overwrite the input
                 clearIncomplete: false, //clear the incomplete input on blur
                 clearIncomplete: false, //clear the incomplete input on blur
+                autoCasing: null, //upper | lower automatic casing of the input
                 aliases: {}, //aliases definitions => see jquery.inputmask.extentions.js
                 aliases: {}, //aliases definitions => see jquery.inputmask.extentions.js
                 definitions: {
                 definitions: {
                     '9': {
                     '9': {
@@ -289,7 +290,18 @@ This plugin is based on the masked input plugin written by Josh Bush (digitalbus
             //these are needed to handle the non-greedy mask repetitions
             //these are needed to handle the non-greedy mask repetitions
             function setBufferElement(buffer, position, element) {
             function setBufferElement(buffer, position, element) {
                 prepareBuffer(buffer, position);
                 prepareBuffer(buffer, position);
-                buffer[position] = element;
+                
+                var elem = element;
+                switch(opts.autoCasing){
+                	case "upper":
+                		elem = element.toUpperCase();
+                		break;
+                	case "lower":
+                		elem = element.toLowerCase();
+                		break;
+                }
+                
+                buffer[position] = elem;
             }
             }
             function getBufferElement(buffer, position) {
             function getBufferElement(buffer, position) {
                 prepareBuffer(buffer, position);
                 prepareBuffer(buffer, position);