浏览代码

added isComplete function

Robin Herbots 13 年之前
父节点
当前提交
0a83549035
共有 2 个文件被更改,包括 33 次插入16 次删除
  1. 14 3
      README.md
  2. 19 13
      js/jquery.inputmask.js

+ 14 - 3
README.md

@@ -2,7 +2,7 @@
 
 jquery.inputmask is a jquery plugin which create an input mask.
 
-Copyright (c) 2010 - 2012 Robin Herbots
+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'.
@@ -55,7 +55,7 @@ In the jquery.inputmask.extensions.js you find a full date input validation whic
 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:
+## Usage:
 
 Include the js-files:
 
@@ -75,7 +75,7 @@ $(document).ready(function(){
 });
 ```
 
-## Extra options:
+## Options:
 
 ### change the placeholder
 
@@ -325,6 +325,17 @@ $(document).ready(function(){
 								} });
 });
 ```
+### isComplete
+
+Verify wheter the current value is complete or not.
+
+```javascript
+$(document).ready(function(){
+    if($("#ssn").inputmask("isComplete")){
+		//do something
+	}
+});
+```
 
 ## Supported markup options
 ### RTL attribute

+ 19 - 13
js/jquery.inputmask.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2012 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 1.2.8a
+* Version: 1.2.8b
 */
 
 (function ($) {
@@ -141,6 +141,13 @@
                         else return "";
                     case "hasMaskedValue": //check wheter the returned value is masked or not; currently only works reliable when using jquery.val fn to retrieve the value 
                         return this.data('inputmask') ? !this.data('inputmask')['autoUnmask'] : false;
+					case "isComplete":
+						var tests = this.data('inputmask')['tests'];
+                        var _buffer = this.data('inputmask')['_buffer'];
+                        opts.greedy = this.data('inputmask')['greedy'];
+                        opts.repeat = this.data('inputmask')['repeat'];
+                        opts.definitions = this.data('inputmask')['definitions'];
+						return isComplete(this);
                     default:
                         //check if the fn is an alias
                         if (!resolveAlias(fn)) {
@@ -536,6 +543,17 @@
                     return caretpos;
                 }
             };
+			
+			function isComplete(npt) {
+                var complete = true, nptValue = npt._valueGet(), ml = nptValue.length;
+                for (var i = 0; i < ml; i++) {
+                    if (isMask(i) && nptValue.charAt(i) == getPlaceHolder(i)) {
+                        complete = false;
+                        break;
+                    }
+                }
+                return complete;
+            }
 
             function mask(el) {
                 var $input = $(el);
@@ -705,18 +723,6 @@
                 installEventRuler(el);
 
                 //private functions
-                function isComplete(npt) {
-                    var complete = true, nptValue = npt._valueGet(), ml = nptValue.length;
-                    for (var i = 0; i < ml; i++) {
-                        if (isMask(i) && nptValue.charAt(i) == getPlaceHolder(i)) {
-                            complete = false;
-                            break;
-                        }
-                    }
-                    return complete;
-                }
-
-
                 function installEventRuler(npt) {
                     var events = $._data(npt).events;