<input
onkeypress="return event.keyCode>=48&&event.keyCode<=57||event.keyCode==46"
onpaste="return !clipboardData.getData('text').match(/\D/)"
ondragenter="return false"
style="ime-mode:Disabled"
>
onkeypress="return event.keyCode>=48&&event.keyCode<=57||event.keyCode==46"
onpaste="return !clipboardData.getData('text').match(/\D/)"
ondragenter="return false"
style="ime-mode:Disabled"
>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head><body>
<form name="form1" method="post" action="">
<input type="text" name="textfield" onkeyup="onlyNumber(this);" onChange="onlyNumber(this);">
</form>
<script language="javascript">
function onlyNumber(e){
if(isNaN(parseFloat(e.value))){
return e.value="";
}
if(parseFloat(e.value)!=e.value){
return e.value=parseFloat(e.value);
}
}
</script>
</body>
</html>