Sha256: 715d1a5f5e0f2c7d83c5030374e52852a5c43ceb8fe6e4e68c6350184aed3494

Contents?: true

Size: 730 Bytes

Versions: 48

Compression:

Stored size: 730 Bytes

Contents

(function ($){
  $.fn.regexMask = function (mask) {
    if (!mask) {
      throw 'mandatory mask argument missing';
    } else if (mask == 'float') {
      mask = /^-?(\d,)*\d*(\.\d*)?$/;
    } else if (mask == 'integer') {
      mask = /^-?\d*$/;
    } else {
      try {
        mask.test("");
      } catch(e) {
        throw 'mask regex need to support test method';
      }
    }
    $(this).keypress(function (event) {
      if (!event.charCode) return true;
      var part1 = this.value.substring(0,this.selectionStart);
      var part2 = this.value.substring(this.selectionEnd,this.value.length);
      if (!mask.test(part1 + String.fromCharCode(event.charCode) + part2))
        return false;
    });
  };
})(jQuery);


Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
incline-0.3.14 app/assets/javascripts/incline/regexMask.js
incline-0.3.13 app/assets/javascripts/incline/regexMask.js
incline-0.3.12 app/assets/javascripts/incline/regexMask.js
incline-0.3.11 app/assets/javascripts/incline/regexMask.js
incline-0.3.10 app/assets/javascripts/incline/regexMask.js
incline-0.3.9 app/assets/javascripts/incline/regexMask.js
incline-0.3.8 app/assets/javascripts/incline/regexMask.js
incline-0.3.7 app/assets/javascripts/incline/regexMask.js
incline-0.3.6 app/assets/javascripts/incline/regexMask.js
incline-0.3.5 app/assets/javascripts/incline/regexMask.js
incline-0.3.4 app/assets/javascripts/incline/regexMask.js
incline-0.3.3 app/assets/javascripts/incline/regexMask.js
incline-0.3.2 app/assets/javascripts/incline/regexMask.js
incline-0.3.1 app/assets/javascripts/incline/regexMask.js
incline-0.3.0 app/assets/javascripts/incline/regexMask.js
incline-0.2.36 app/assets/javascripts/incline/regexMask.js
incline-0.2.35 app/assets/javascripts/incline/regexMask.js
incline-0.2.34 app/assets/javascripts/incline/regexMask.js
incline-0.2.28 app/assets/javascripts/incline/regexMask.js
incline-0.2.27 app/assets/javascripts/incline/regexMask.js