/// /// // controls $.fn.number = function () { return this.each(function () { function changed(e) { //if (this.className.indexOf('inp_priority') >= 0 && this.value == 0) { // this.value = ''; //} //else { var m = this.value.match(/[0-9]+/g); if (!m) { this.value = '1'; } else { this.value = m.join(''); } //} } function keydown(e) { if (e.altKey || e.ctrlKey) { return true; } switch (e.keyCode) { case 8: // backspace case 9: // tab case 46: // del return true; } if ($(this).hasClass('inp_priority') && (e.keyCode == 96 || e.keyCode == 48) && $(this).val() == '') { return false; } //if ('0123456789'.indexOf(e.key) >= 0) { // return true; //} if ((e.keyCode >= 96 && e.keyCode <= 105) || (e.keyCode >= 48 && e.keyCode <= 57)) { return true; } return false; } $(this).unbind('change.num').unbind('keydown.num').bind('change.num', changed).bind('keydown.num', keydown); }); };