代码如下:
[quote]<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
input[text] {
ime-mode: auto !important;
}
</style>
<script type="text/javascript">
function checkkey(value,e){
var key = window.event?e.keyCode:e.which;
if( (key > 95 && key < 106) ||
(key > 47 && key < 60) ||
(key == 110 && value.indexOf(".") < 0 )||
(key == 190 && value.indexOf(".") < 0 )){
}else if(key !=8){
if (window.event) //IE
{
e.returnValue = false; //event.returnValue=false 效果相同.
}
else //Firefox
{
e.preventDefault();
}
}
}
</script>
</head>
<body>
只允许输入数字与小数点<input type="text" name="test" id="test" οnkeydοwn="checkkey(this.value,event)" style="ime-mode:disabled" />
</body>
</html>[/quote]
[quote]<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
input[text] {
ime-mode: auto !important;
}
</style>
<script type="text/javascript">
function checkkey(value,e){
var key = window.event?e.keyCode:e.which;
if( (key > 95 && key < 106) ||
(key > 47 && key < 60) ||
(key == 110 && value.indexOf(".") < 0 )||
(key == 190 && value.indexOf(".") < 0 )){
}else if(key !=8){
if (window.event) //IE
{
e.returnValue = false; //event.returnValue=false 效果相同.
}
else //Firefox
{
e.preventDefault();
}
}
}
</script>
</head>
<body>
只允许输入数字与小数点<input type="text" name="test" id="test" οnkeydοwn="checkkey(this.value,event)" style="ime-mode:disabled" />
</body>
</html>[/quote]