EasyUI Forum
May 02, 2024, 10:44:32 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: numberbox bug  (Read 13814 times)
anton.dutov
Newbie
*
Posts: 27


View Profile
« on: July 09, 2012, 05:51:17 AM »

numberbox alloows incorect input like '0.1.1.1.1.1.1'
Previsiosly i posted code wich wiil handle this case
Code:
function num_filter(e/*event*/, o /* object*/) {
  var o = $(o);
  var v = o.val();
  var keyCode = ('which' in e) ? e.which : e.keyCode;
  if ($.inArray(keyCode, [8, 9, 35, 36, 37, 38, 39, 40, 45, 46]) != -1) // Special keys
    return true;
  if (keyCode == 190) { // Dot
    if (v.indexOf('.') == -1) { // no dot in input
      if (v == '') // Val is empty? add '0' (value becomes 0.)
        o.val('0');
      return true;
    }
    return false;
  }
  isNumeric = (keyCode >= 48 /* 0 */       && keyCode <= 57  /* 9 */) ||
              (keyCode >= 96 /* NUMPAD0 */ && keyCode <= 105 /* NUMPAD9 */);
  modifiers = (e.altKey || e.ctrlKey || e.shiftKey);
  return isNumeric || modifiers;
}
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!