Web page effects limit you can only enter numbers and decimals
You can only enter a number, and the range is between 0.0~999.9, a decimal can be entered only one digit, the integer up to 3 digits, allowing no decimal.
Requirements: An input box, you can only enter a number or decimal point, other characters do not display;
The integer part is entered up to three bits;
The decimal part is entered at most one digit.
1: 2: 3: <script language=javascript> 1: 2:function limite (object) & nbsp; 3: { 4: if (isNaN (object.value)) 5: { 6: dosubstring (object); 7: } 8: else 9: { 10: var index = Object.value.indexof ('. '); 11: if (Index > 0) 12: { 13: if ( Object.value.length > Index + 2) 14: dosubstring (object); 15:&NBSP;&NBSP;&Nbsp; } 16: else 17: { 18: var ivalue = parseint (obaject.value); 19: if (Ivalue < 0 | | ivalue >=1000) 20: dosubstring (object); 21: } 22: } :} 24:function dosubstring (object ) : { 26: object.value=object.value.substring (0,object.value.length-1); :}</script>
4: 5:
6: <body>
7: <input onpropertychange= "Limite (this)" Maxlength= "5" name= "Amount"/>
8: </body>
9: