This is a good alternative when some Browsers Do not support type number.
1 <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en"
2 Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
3 <HTML xmlns = "http://www.w3.org/1999/xhtml">
4 <Head>
5 <Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
6 <Title> positive integer input only </title>
7
8 </Head>
9
10 <Body>
11 <SCRIPT>
12 // Void function (window, undefined ){
13 Window. onload = Function (){
14 VaR Doc = Document, list = Doc. getelementsbytagname ('input ');
15
16
17 Availablenumberinput (list );
18 }
19 Function Availablenumberinput (inputs ){
20 VaR Len = inputs. length, I, reg =/^ (8 | 9 | 4 [8-9] | 5 [0-7] | 9 [6-9] | 10 [0-5]) $/ig;
21
22 Document. onmousedown = Function (){
23 Try {
24 Document. selection. Empty ()
25 } Catch (E ){
26 Getselection (). removeallranges ()
27 }
28 }
29 For (I = Len; I> 0; (inputs [-- I]. onkeydown = Function (E ){
30 E = Window. Event | E;
31 VaR Target = E. srcelement | e.tar get, code = E. charcode | E. keycode;
32 Reg. lastindex = 0;
33 If (! Reg. Test (CODE) | E. shiftkey ){
34 Return False ;
35 }
36 Target. value = '0' & (target. value = '');
37 }, Inputs [I]. oncontextmenu = Function (){
38 Return False ;
39 }), Inputs [I]. style. imemode = 'Disabled '){
40 }
41 }
42 // } (Window );
43 </SCRIPT>
44
45 Drag a text string into the input box to see it <br/>
46 <Input type = "text"/> <br/>
47 <Input type = "text"/> <br/>
48 <Input type = "text"/>
49 </Body>
50 </Html>