Skip to content

Commit

Permalink
fix error with numeric inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
adam brill committed Mar 12, 2014
1 parent 9fb40af commit c48f0ac
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions numeric/jquery.numeric.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,10 @@ $.fn.removeNumeric = function()
// Based on code from http://javascript.nwbox.com/cursor_position/ (Diego Perini <dperini@nwbox.com>)
$.fn.getSelectionStart = function(o)
{
if (o.createTextRange)
if(o.type === "number"){
return undefined;
}
else if (o.createTextRange)
{
var r = document.selection.createRange().duplicate();
r.moveEnd('character', o.value.length);
Expand All @@ -257,7 +260,10 @@ $.fn.getSelectionStart = function(o)
// Based on code from http://javascript.nwbox.com/cursor_position/ (Diego Perini <dperini@nwbox.com>)
$.fn.getSelectionEnd = function(o)
{
if (o.createTextRange) {
if(o.type === "number"){
return undefined;
}
else if (o.createTextRange) {
var r = document.selection.createRange().duplicate()
r.moveStart('character', -o.value.length)
return r.text.length
Expand All @@ -272,7 +278,10 @@ $.fn.setSelection = function(o, p)
// only set if p is an array of length 2
if(p && p.constructor == Array && p.length == 2)
{
if (o.createTextRange)
if(o.type === "number") {
o.focus();
}
else if (o.createTextRange)
{
var r = o.createTextRange();
r.collapse(true);
Expand All @@ -288,4 +297,4 @@ $.fn.setSelection = function(o, p)
}
};

})(jQuery);
})(jQuery);

0 comments on commit c48f0ac

Please sign in to comment.