<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<script>
function chackNum(obj){
var checkReg=/\.$/g;
var db=/^[0-9]+([.]{1}[0-9]{1,2})?$/
obj.value=obj.value.replace(/[^\d\.]/g,'');
if(checkReg.test(obj.value)){
if(obj.value.indexOf(".")!=(obj.value.length-1)){
obj.value=obj.value.replace(/\.$/,'');
}
}else{
if(!db.test(obj.value)){
obj.value=obj.value.replace(/\d$/,'');
}
}
}
</script>
<body>
<input type="text" id="test" οnkeyup="chackNum(this)" />
</body>
</html>
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<script>
function chackNum(obj){
var checkReg=/\.$/g;
var db=/^[0-9]+([.]{1}[0-9]{1,2})?$/
obj.value=obj.value.replace(/[^\d\.]/g,'');
if(checkReg.test(obj.value)){
if(obj.value.indexOf(".")!=(obj.value.length-1)){
obj.value=obj.value.replace(/\.$/,'');
}
}else{
if(!db.test(obj.value)){
obj.value=obj.value.replace(/\d$/,'');
}
}
}
</script>
<body>
<input type="text" id="test" οnkeyup="chackNum(this)" />
</body>
</html>