OSDN Git Service

added 'white-space: nowrap' to th tag
[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-2005 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.2 2005-03-16 08:07:50 kimitake Exp $\r
15   * $NucleusJP: numbercheck.js,v 1.2 2005/03/12 06:19:04 kimitake Exp $\r
16   */\r
17 \r
18 function checkNumeric(f)\r
19 {\r
20         newval='';\r
21         dot = false;\r
22         for (i = 0; i < f.value.length; i++) {\r
23                 c = f.value.substring(i,i+1);\r
24                 if (isInteger(c) || ((c == '.')&&(dot == false)) || ((i == 0)&&(c == '-'))) {\r
25                         newval += c;\r
26                         if (c == '.') {\r
27                                 dot = true;\r
28                         }\r
29                 }\r
30         }\r
31         f.value = newval;\r
32 }\r
33 \r
34 function isInteger(value)\r
35 {\r
36         return (parseInt(value) == value);\r
37 }\r