1 <SCRIPT>
2 function mygetkeycode (e ){
3 var code;
4 If (! E) var E = Window. event;
5 If (E. keycode ){
6 code = E. keycode;
7} else if (E. Which ){
8 code = E. Which;
9}
10 return code;
11}
12
13 //-2.36 onkeypress
14 function mychecknum (OBJ, E)
15 {
16 var code = mygetkeycode (E );
17 if (Code <45 response code> 57 response code = 47) & code! = 45 & code! = 9 & code! = 8) return false;
18 if (code = 46 & obj. value. indexof (".")>-1) return false;
19 Return true;
20}
21
22 // 325 onkeypress
23 function mycheckint (OBJ, E)
24 {
25 var code = mygetkeycode (E );
26 if (Code <48 response code> 57) & code! = 45 & code! = 9 & code! = 8) return false;
27 return true;
28}
29 </SCRIPT>
30 can only be an integer
31 <input type = "text" name = "txtname" onkeypress = "Return mycheckint (this, event)"> <br/>
32 decimal places
33 <input type = "text" name = "txtname" onkeypress = "Return mychecknum (this, event)"> <br/>
34