ソースを参照

better date validation

Robin Herbots 8 年 前
コミット
00dc61c7a0
46 ファイル変更77 行追加83 行削除
  1. 1 1
      bower.json
  2. 1 1
      component.json
  3. 1 1
      composer.json
  4. 1 1
      dist/inputmask/bindings/inputmask.binding.js
  5. 1 1
      dist/inputmask/dependencyLibs/inputmask.dependencyLib.jqlite.js
  6. 1 1
      dist/inputmask/dependencyLibs/inputmask.dependencyLib.jquery.js
  7. 1 1
      dist/inputmask/dependencyLibs/inputmask.dependencyLib.js
  8. 1 1
      dist/inputmask/global/document.js
  9. 1 1
      dist/inputmask/global/window.js
  10. 9 8
      dist/inputmask/inputmask.date.extensions.js
  11. 1 1
      dist/inputmask/inputmask.extensions.js
  12. 1 1
      dist/inputmask/inputmask.js
  13. 1 1
      dist/inputmask/inputmask.numeric.extensions.js
  14. 1 1
      dist/inputmask/inputmask.phone.extensions.js
  15. 1 1
      dist/inputmask/jquery.inputmask.js
  16. 1 1
      dist/inputmask/phone-codes/phone-be.js
  17. 1 1
      dist/inputmask/phone-codes/phone-ca.js
  18. 1 1
      dist/inputmask/phone-codes/phone-nl.js
  19. 1 1
      dist/inputmask/phone-codes/phone-ru.js
  20. 1 1
      dist/inputmask/phone-codes/phone-uk.js
  21. 1 1
      dist/inputmask/phone-codes/phone-us.js
  22. 1 1
      dist/inputmask/phone-codes/phone.js
  23. 9 8
      dist/jquery.inputmask.bundle.js
  24. 1 1
      dist/min/inputmask/bindings/inputmask.binding.min.js
  25. 1 1
      dist/min/inputmask/dependencyLibs/inputmask.dependencyLib.jqlite.min.js
  26. 1 1
      dist/min/inputmask/dependencyLibs/inputmask.dependencyLib.jquery.min.js
  27. 1 1
      dist/min/inputmask/dependencyLibs/inputmask.dependencyLib.min.js
  28. 1 1
      dist/min/inputmask/global/document.min.js
  29. 1 1
      dist/min/inputmask/global/window.min.js
  30. 2 2
      dist/min/inputmask/inputmask.date.extensions.min.js
  31. 1 1
      dist/min/inputmask/inputmask.extensions.min.js
  32. 1 1
      dist/min/inputmask/inputmask.min.js
  33. 1 1
      dist/min/inputmask/inputmask.numeric.extensions.min.js
  34. 1 1
      dist/min/inputmask/inputmask.phone.extensions.min.js
  35. 1 1
      dist/min/inputmask/jquery.inputmask.min.js
  36. 1 1
      dist/min/inputmask/phone-codes/phone-be.min.js
  37. 1 1
      dist/min/inputmask/phone-codes/phone-ca.min.js
  38. 1 1
      dist/min/inputmask/phone-codes/phone-nl.min.js
  39. 1 1
      dist/min/inputmask/phone-codes/phone-ru.min.js
  40. 1 1
      dist/min/inputmask/phone-codes/phone-uk.min.js
  41. 1 1
      dist/min/inputmask/phone-codes/phone-us.min.js
  42. 1 1
      dist/min/inputmask/phone-codes/phone.min.js
  43. 2 2
      dist/min/jquery.inputmask.bundle.min.js
  44. 14 22
      js/inputmask.date.extensions.js
  45. 1 1
      js/jquery.inputmask.js
  46. 1 1
      package.json

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "inputmask",
-  "version": "4.0.0-53",
+  "version": "4.0.0-54",
   "main": [
 	  "./dist/inputmask/inputmask.js",
 	  "./dist/inputmask/inputmask.extensions.js",

+ 1 - 1
component.json

@@ -2,7 +2,7 @@
 	"name": "inputmask",
 	"repository": "robinherbots/Inputmask",
 	"description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
-	"version": "4.0.0-53",
+	"version": "4.0.0-54",
 	"keywords": [
 		"jquery",
 		"plugins",

+ 1 - 1
composer.json

@@ -1,7 +1,7 @@
 {
   "name": "robinherbots/inputmask",
   "description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
-  "version": "4.0.0-53",
+  "version": "4.0.0-54",
   "type": "library",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "homepage": "http://robinherbots.github.io/Inputmask",

+ 1 - 1
dist/inputmask/bindings/inputmask.binding.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-53
+* Version: 4.0.0-54
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/dependencyLibs/inputmask.dependencyLib.jqlite.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-53
+* Version: 4.0.0-54
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/dependencyLibs/inputmask.dependencyLib.jquery.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-53
+* Version: 4.0.0-54
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/dependencyLibs/inputmask.dependencyLib.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-53
+* Version: 4.0.0-54
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/global/document.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-53
+* Version: 4.0.0-54
 */
 
 "function" == typeof define && define.amd ? define(function() {

+ 1 - 1
dist/inputmask/global/window.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-53
+* Version: 4.0.0-54
 */
 
 "function" == typeof define && define.amd ? define(function() {

+ 9 - 8
dist/inputmask/inputmask.date.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-53
+* Version: 4.0.0-54
 */
 
 !function(factory) {
@@ -14,8 +14,8 @@
             return ndx;
         }).join("|") + ")+|.", opts.tokenizer = new RegExp(opts.tokenizer, "g")), opts.tokenizer;
     }
-    function isLeapYear(year) {
-        return 29 === new Date(year, 2, 0).getDate();
+    function isValidDate(dateParts) {
+        return 29 == dateParts.day && !isFinite(dateParts.rawyear) || new Date(dateParts.year, dateParts.month, 0).getDate() >= dateParts.day;
     }
     function isDateInRange(maskDate, opts) {
         var result = !0;
@@ -42,8 +42,9 @@
                 mask = mask.slice((value + match[0]).length), targetProp = void 0;
             }
             return void 0 !== targetProp && ("year" === targetProp ? (dateObj[targetProp] = extendYear(mask), 
-            dateObj["raw" + targetProp] = mask) : dateObj[targetProp] = mask.replace(/[^0-9]/g, "0")), 
-            dateObj.date = new Date(dateObj.year + "-" + dateObj.month + "-" + dateObj.day + "T" + dateObj.hour + ":" + dateObj.minutes + ":" + dateObj.seconds), 
+            dateObj["raw" + targetProp] = value) : dateObj[targetProp] = mask.replace(/[^0-9]/g, "0")), 
+            dateObj.date = new Date(dateObj.year + "-" + dateObj.month + "-" + dateObj.day), 
+            dateObj.datetime = new Date(dateObj.year + "-" + dateObj.month + "-" + dateObj.day + "T" + dateObj.hour + ":" + dateObj.minutes + ":" + dateObj.seconds), 
             dateObj;
         }
     }
@@ -104,9 +105,9 @@
             min: null,
             max: null,
             postValidation: function(buffer, currentResult, opts) {
-                var dateParts = analyseMask(buffer.join(""), opts.inputFormat, opts), result = currentResult;
-                return result && isFinite(dateParts.rawyear) && (result = result && ("29" !== dateParts.day || !isLeapYear(dateParts.rawyear))), 
-                result && dateParts.date.getTime() === dateParts.date.getTime() && (result = result && isDateInRange(dateParts.date, opts)), 
+                var result = currentResult, dateParts = analyseMask(buffer.join(""), opts.inputFormat, opts);
+                return result && dateParts.date.getTime() === dateParts.date.getTime() && (result = isValidDate(dateParts)), 
+                result && dateParts.datetime.getTime() === dateParts.datetime.getTime() && (result = isDateInRange(dateParts.date, opts)), 
                 result;
             },
             onKeyDown: function(e, buffer, caretPos, opts) {

+ 1 - 1
dist/inputmask/inputmask.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-53
+* Version: 4.0.0-54
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/inputmask.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-53
+* Version: 4.0.0-54
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/inputmask.numeric.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-53
+* Version: 4.0.0-54
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/inputmask.phone.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-53
+* Version: 4.0.0-54
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/jquery.inputmask.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-53
+* Version: 4.0.0-54
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/phone-codes/phone-be.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-53
+* Version: 4.0.0-54
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/phone-codes/phone-ca.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-53
+* Version: 4.0.0-54
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/phone-codes/phone-nl.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-53
+* Version: 4.0.0-54
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/phone-codes/phone-ru.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-53
+* Version: 4.0.0-54
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/phone-codes/phone-uk.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-53
+* Version: 4.0.0-54
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/phone-codes/phone-us.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-53
+* Version: 4.0.0-54
 */
 
 !function(factory) {

+ 1 - 1
dist/inputmask/phone-codes/phone.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-53
+* Version: 4.0.0-54
 */
 
 !function(factory) {

+ 9 - 8
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-53
+* Version: 4.0.0-54
 */
 
 !function(modules) {
@@ -1927,8 +1927,8 @@
                 return ndx;
             }).join("|") + ")+|.", opts.tokenizer = new RegExp(opts.tokenizer, "g")), opts.tokenizer;
         }
-        function isLeapYear(year) {
-            return 29 === new Date(year, 2, 0).getDate();
+        function isValidDate(dateParts) {
+            return 29 == dateParts.day && !isFinite(dateParts.rawyear) || new Date(dateParts.year, dateParts.month, 0).getDate() >= dateParts.day;
         }
         function isDateInRange(maskDate, opts) {
             var result = !0;
@@ -1955,8 +1955,9 @@
                     mask = mask.slice((value + match[0]).length), targetProp = void 0;
                 }
                 return void 0 !== targetProp && ("year" === targetProp ? (dateObj[targetProp] = extendYear(mask), 
-                dateObj["raw" + targetProp] = mask) : dateObj[targetProp] = mask.replace(/[^0-9]/g, "0")), 
-                dateObj.date = new Date(dateObj.year + "-" + dateObj.month + "-" + dateObj.day + "T" + dateObj.hour + ":" + dateObj.minutes + ":" + dateObj.seconds), 
+                dateObj["raw" + targetProp] = value) : dateObj[targetProp] = mask.replace(/[^0-9]/g, "0")), 
+                dateObj.date = new Date(dateObj.year + "-" + dateObj.month + "-" + dateObj.day), 
+                dateObj.datetime = new Date(dateObj.year + "-" + dateObj.month + "-" + dateObj.day + "T" + dateObj.hour + ":" + dateObj.minutes + ":" + dateObj.seconds), 
                 dateObj;
             }
         }
@@ -2017,9 +2018,9 @@
                 min: null,
                 max: null,
                 postValidation: function(buffer, currentResult, opts) {
-                    var dateParts = analyseMask(buffer.join(""), opts.inputFormat, opts), result = currentResult;
-                    return result && isFinite(dateParts.rawyear) && (result = result && ("29" !== dateParts.day || !isLeapYear(dateParts.rawyear))), 
-                    result && dateParts.date.getTime() === dateParts.date.getTime() && (result = result && isDateInRange(dateParts.date, opts)), 
+                    var result = currentResult, dateParts = analyseMask(buffer.join(""), opts.inputFormat, opts);
+                    return result && dateParts.date.getTime() === dateParts.date.getTime() && (result = isValidDate(dateParts)), 
+                    result && dateParts.datetime.getTime() === dateParts.datetime.getTime() && (result = isDateInRange(dateParts.date, opts)), 
                     result;
                 },
                 onKeyDown: function(e, buffer, caretPos, opts) {

ファイルの差分が大きいため隠しています
+ 1 - 1
dist/min/inputmask/bindings/inputmask.binding.min.js


ファイルの差分が大きいため隠しています
+ 1 - 1
dist/min/inputmask/dependencyLibs/inputmask.dependencyLib.jqlite.min.js


+ 1 - 1
dist/min/inputmask/dependencyLibs/inputmask.dependencyLib.jquery.min.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-53
+* Version: 4.0.0-54
 */
 
 !function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?module.exports=e(require("jquery")):window.dependencyLib=e(jQuery)}(function(e){return e});

ファイルの差分が大きいため隠しています
+ 1 - 1
dist/min/inputmask/dependencyLibs/inputmask.dependencyLib.min.js


+ 1 - 1
dist/min/inputmask/global/document.min.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-53
+* Version: 4.0.0-54
 */
 
 "function"==typeof define&&define.amd?define(function(){return document}):"object"==typeof exports&&(module.exports=document);

+ 1 - 1
dist/min/inputmask/global/window.min.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/Inputmask
 * Copyright (c) 2010 - 2017 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-53
+* Version: 4.0.0-54
 */
 
 "function"==typeof define&&define.amd?define(function(){return window}):"object"==typeof exports&&(module.exports=window);

ファイルの差分が大きいため隠しています
+ 2 - 2
dist/min/inputmask/inputmask.date.extensions.min.js


ファイルの差分が大きいため隠しています
+ 1 - 1
dist/min/inputmask/inputmask.extensions.min.js


ファイルの差分が大きいため隠しています
+ 1 - 1
dist/min/inputmask/inputmask.min.js


ファイルの差分が大きいため隠しています
+ 1 - 1
dist/min/inputmask/inputmask.numeric.extensions.min.js


ファイルの差分が大きいため隠しています
+ 1 - 1
dist/min/inputmask/inputmask.phone.extensions.min.js


ファイルの差分が大きいため隠しています
+ 1 - 1
dist/min/inputmask/jquery.inputmask.min.js


ファイルの差分が大きいため隠しています
+ 1 - 1
dist/min/inputmask/phone-codes/phone-be.min.js


ファイルの差分が大きいため隠しています
+ 1 - 1
dist/min/inputmask/phone-codes/phone-ca.min.js


ファイルの差分が大きいため隠しています
+ 1 - 1
dist/min/inputmask/phone-codes/phone-nl.min.js


ファイルの差分が大きいため隠しています
+ 1 - 1
dist/min/inputmask/phone-codes/phone-ru.min.js


ファイルの差分が大きいため隠しています
+ 1 - 1
dist/min/inputmask/phone-codes/phone-uk.min.js


ファイルの差分が大きいため隠しています
+ 1 - 1
dist/min/inputmask/phone-codes/phone-us.min.js


ファイルの差分が大きいため隠しています
+ 1 - 1
dist/min/inputmask/phone-codes/phone.min.js


ファイルの差分が大きいため隠しています
+ 2 - 2
dist/min/jquery.inputmask.bundle.min.js


+ 14 - 22
js/inputmask.date.extensions.js

@@ -76,8 +76,9 @@
         return opts.tokenizer;
     }
 
-    function isLeapYear(year) {
-        return new Date(year, 2, 0).getDate() === 29;
+    function isValidDate(dateParts) {
+        if (dateParts.day == 29 && !isFinite(dateParts.rawyear)) return true;
+        return new Date(dateParts.year, dateParts.month, 0).getDate() >= dateParts.day;
     }
 
     function isDateInRange(maskDate, opts) {
@@ -112,14 +113,7 @@
         }
 
 
-        var dateObj = {
-            // day:  "01",
-            // month: "01",
-            // year: extendYear("____"),
-            // hour: "00",
-            // minutes: "00",
-            // seconds: "00"
-        }, targetProp, mask = maskString, match;
+        var dateObj = {}, targetProp, mask = maskString, match;
         if (typeof mask === "string") {
             while (match = getTokenizer(opts).exec(format)) {
                 if (match[0].charAt(0) === "d") {
@@ -136,7 +130,7 @@
                     targetProp = "seconds";
                 } else if (formatCode.hasOwnProperty(match[0])) {
                     targetProp = "unmatched";
-                } else { //separatot
+                } else { //separator
                     var value = mask.split(match[0])[0];
                     if (targetProp === "year") {
                         dateObj[targetProp] = extendYear(value);
@@ -150,11 +144,12 @@
             if (targetProp !== undefined) {
                 if (targetProp === "year") {
                     dateObj[targetProp] = extendYear(mask);
-                    dateObj["raw" + targetProp] = mask;
+                    dateObj["raw" + targetProp] = value;
                 }
                 else dateObj[targetProp] = mask.replace(/[^0-9]/g, "0");
             }
-            dateObj.date = new Date(dateObj.year + "-" + dateObj.month + "-" + dateObj.day + "T" + dateObj.hour + ":" + dateObj.minutes + ":" + dateObj.seconds);
+            dateObj.date = new Date(dateObj.year + "-" + dateObj.month + "-" + dateObj.day);
+            dateObj.datetime = new Date(dateObj.year + "-" + dateObj.month + "-" + dateObj.day + "T" + dateObj.hour + ":" + dateObj.minutes + ":" + dateObj.seconds);
             return dateObj;
         }
         return undefined;
@@ -179,17 +174,14 @@
             min: null, //needs to be in the same format as the inputfornat
             max: null, //needs to be in the same format as the inputfornat
             postValidation: function (buffer, currentResult, opts) {
-                var dateParts = analyseMask(buffer.join(""), opts.inputFormat, opts);
-                var result = currentResult;
-
-                if (result && isFinite(dateParts.rawyear)) {
-                    result = result && (dateParts.day !== "29" || !isLeapYear(dateParts.rawyear));
+                var result = currentResult, dateParts = analyseMask(buffer.join(""), opts.inputFormat, opts);
+                if (result && dateParts.date.getTime() === dateParts.date.getTime()) {
+                    result = isValidDate(dateParts);
                 }
-                if (result) {
-                    if (dateParts.date.getTime() === dateParts.date.getTime()) { //check for a valid date ~ an invalid date returns NaN which isn't equal
-                        result = result && isDateInRange(dateParts.date, opts);
-                    }
+                if (result && dateParts.datetime.getTime() === dateParts.datetime.getTime()) { //check for a valid date ~ an invalid date returns NaN which isn't equal
+                    result = isDateInRange(dateParts.date, opts);
                 }
+
                 return result;
             },
             onKeyDown: function (e, buffer, caretPos, opts) {

+ 1 - 1
js/jquery.inputmask.js

@@ -31,7 +31,7 @@
 						});
 					case "getemptymask":
 						return input && input.inputmask ? input.inputmask.getemptymask() : "";
-					case "hasMaskedValue": //check wheter the returned value is masked or not; currently only works reliable when using jquery.val fn to retrieve the value
+					case "hasMaskedValue": //check whether the returned value is masked or not; currently only works reliable when using jquery.val fn to retrieve the value
 						return input && input.inputmask ? input.inputmask.hasMaskedValue() : false;
 					case "isComplete":
 						return input && input.inputmask ? input.inputmask.isComplete() : true;

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "inputmask",
-  "version": "4.0.0-53",
+  "version": "4.0.0-54",
   "description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
   "main": "index.js",
   "files": [