mirror of
https://github.com/transmission/transmission.git
synced 2025-12-20 02:18:42 +00:00
(trunk web) use jQuery to limit the preference dialog's numberic entry fields to only accept numbers. (the HOWTO for this was at http://www.west-wind.com/weblog/posts/2011/Apr/22/Restricting-Input-in-HTML-Textboxes-to-Numeric-Values)
This commit is contained in:
@@ -309,3 +309,28 @@ Prefs.getClutchPrefs = function( o )
|
||||
o[key] = Prefs.getValue( key, Prefs._Defaults[key] );
|
||||
return o;
|
||||
};
|
||||
|
||||
|
||||
// forceNumeric() plug-in implementation
|
||||
jQuery.fn.forceNumeric = function () {
|
||||
return this.each(function () {
|
||||
$(this).keydown(function (e) {
|
||||
var key = e.which || e.keyCode;
|
||||
return !e.shiftKey && !e.altKey && !e.ctrlKey &&
|
||||
// numbers
|
||||
key >= 48 && key <= 57 ||
|
||||
// Numeric keypad
|
||||
key >= 96 && key <= 105 ||
|
||||
// comma, period and minus, . on keypad
|
||||
key == 190 || key == 188 || key == 109 || key == 110 ||
|
||||
// Backspace and Tab and Enter
|
||||
key == 8 || key == 9 || key == 13 ||
|
||||
// Home and End
|
||||
key == 35 || key == 36 ||
|
||||
// left and right arrows
|
||||
key == 37 || key == 39 ||
|
||||
// Del and Ins
|
||||
key == 46 || key == 45;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user