[Custom Masks] Issues with min/max with the numeric masks

[Custom Masks] Issues with min/max with the numeric masks

  
Forge Component
(21)
Published on 7 Mar by Jogait
21 votes
Published on 7 Mar by Jogait

It's blowing up in the JavaScript, and it seems absolutely sensible that it's blowing up in the JavaScript.

In the OSPage_InputMaskNumber function, it is exploding because unmaskedValue is undefined and therefore has no replace function:

maskOpts = $.extend(maskOpts, {groupSeparator: groupSep, autoGroup: true,
    onUnMask: function(maskedValue, unmaskedValue){
                    if(decimalSep != "."){ return unmaskedValue.replace(/\./g, "").replace(/,/g, ".");
                    } else{ return unmaskedValue.replace(/,/g, "").replace(/'/g, "");}
              }});

It seems to be being called rather directly with an explicit undefined value in onBeforeWrite in MaskPlugin:

case "checkval":
                            var unmasked;
                            if (function(opts) {
                                opts.parseMinMaxOptions === undefined && (null !== opts.min && (opts.min = opts.min.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator),"g"), ""),
                                "," === opts.radixPoint && (opts.min = opts.min.replace(opts.radixPoint, ".")),
                                opts.min = isFinite(opts.min) ? parseFloat(opts.min) : NaN,
                                isNaN(opts.min) && (opts.min = Number.MIN_VALUE)),
                                null !== opts.max && (opts.max = opts.max.toString().replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator),"g"), ""),
                                "," === opts.radixPoint && (opts.max = opts.max.replace(opts.radixPoint, ".")),
                                opts.max = isFinite(opts.max) ? parseFloat(opts.max) : NaN,
                                isNaN(opts.max) && (opts.max = Number.MAX_VALUE)),
                                opts.parseMinMaxOptions = "done");
                            }(opts),
                            null !== opts.min || null !== opts.max) {
                                if (unmasked = opts.onUnMask(buffer.join(""), undefined, $.extend({}, opts, {
                                    unmaskAsNumber: !0
                                })),

The code triggers because we have a min and a max set.

So... did onUnMask means to refer to maskedValue instead, or is the opts.onUnMask function inappropriately calling with the unmaskedValue as undefined?

This is our option set, FWIW:

SyntaxEditor Code Snippet

{clearMaskOnLostFocus: false, allowMinus:false, min: 0, max: 69, suffix: ""%"", unmaskAsNumber: true}

-- Ritchie Annand