Features
- Only numbers
- A unique dot (.)
But...i need improve to allow user digits only two numbers after the dot
Valid examples:
- 121213
- 123450.10
- 12345678910111213.39
The current code (adapted from this, not need to keep exactly the same code...) :
<HTML>
<HEAD>
<SCRIPT language=Javascript>
<!--
function isNumberKey(evt,obj){
var containsDot = obj.value.indexOf(".");
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57)){
if(charCode == 46 && containsDot < 0){
return true;
}
return false;
}
return true;
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<INPUT id="txtChar" onkeypress="return isNumberKey(event,this)" type="text" name="txtChar">
</BODY>
</HTML>