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