OSDN Git Service

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