[ Index ]

PHP Cross Reference of Nucleus CMS 3.32

title

Body

[close]

/nucleus/javascript/ -> numbercheck.js (source)

   1  /**
   2    * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/) 
   3    * Copyright (C) 2002-2007 The Nucleus Group
   4    *
   5    * This program is free software; you can redistribute it and/or
   6    * modify it under the terms of the GNU General Public License
   7    * as published by the Free Software Foundation; either version 2
   8    * of the License, or (at your option) any later version.
   9    * (see nucleus/documentation/index.html#license for more info)
  10    *
  11    * script the check (on the clientside) if a entered value
  12    * is a valid number and remove the invalid chars
  13    *
  14    * $Id: numbercheck.js 1116 2007-02-03 08:24:29Z kimitake $
  15    */
  16  
  17  function checkNumeric(f)
  18  {
  19      newval='';
  20      dot = false;
  21      for (i = 0; i < f.value.length; i++) {
  22          c = f.value.substring(i,i+1);
  23          if (isInteger(c) || ((c == '.')&&(dot == false)) || ((i == 0)&&(c == '-'))) {
  24              newval += c;
  25              if (c == '.') {
  26                  dot = true;
  27              }
  28          }
  29      }
  30      f.value = newval;
  31  }
  32  
  33  function isInteger(value)
  34  {
  35      return (parseInt(value) == value);
  36  }


Generated: Tue Feb 12 15:34:36 2008 Cross-referenced by PHPXref 0.7