From 88aa853b91ed534259a4fa466bf4c98ce2339259 Mon Sep 17 00:00:00 2001
From: Topher Nova <topher.a.nova@gmail.com>
Date: Mon, 23 May 2022 11:56:02 -0700
Subject: [PATCH] static value test added

Added a static method that returns a boolean indicating whether or not the current value of a field matches the mask.
---
 src/jquery.mask.js | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/jquery.mask.js b/src/jquery.mask.js
index 54f171c9..69f0835a 100755
--- a/src/jquery.mask.js
+++ b/src/jquery.mask.js
@@ -130,7 +130,7 @@
                 })
                 // clear the value if it not complete the mask
                 .on('focusout.mask', function() {
-                    if (options.clearIfNotMatch && !regexMask.test(p.val())) {
+                    if (options.clearIfNotMatch && !testMaskedVal()) {
                        p.val('');
                    }
                 });
@@ -416,6 +416,10 @@
         jMask.getMaskedVal = function(val) {
            return p.getMasked(false, val);
         };
+        
+        jMask.testMaskedVal = function() {
+            return regexMask.test(p.val());
+        };
 
        jMask.init = function(onlyMask) {
             onlyMask = onlyMask || false;
@@ -561,6 +565,10 @@
     $.fn.cleanVal = function() {
         return this.data('mask').getCleanVal();
     };
+    
+    $.fn.maskMatched = function() {
+        return this.data('mask').testMaskedVal();
+    }
 
     $.applyDataMask = function(selector) {
         selector = selector || $.jMaskGlobals.maskElements;