首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

input 只允许输入100的倍数 怎么写

2012-02-07 
input只允许输入100的倍数 如何写?帮一下忙.[解决办法]if a mod 1000[解决办法] !DOCTYPE html PUBLIC-

input 只允许输入100的倍数 如何写?
帮一下忙.

[解决办法]
if a mod 100=0
[解决办法]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> 无标题文档 </title>
<script type= "text/javascript ">
function check(){
var myt=document.getElementById( "yb ");
if(Number(myt.value)==0 || !(Number(myt.value)%100==0)){
myt.value= " ";
};
}
</script>
</head>

<body>
<input id= "yb " type= "text " onchange= "check() " />
</body>
</html>
[解决办法]
parseInt(value)*100;
[解决办法]
<script type= "text/javascript ">
function CheckNumber(obj)
{
if (Number(obj.value) % 100 == 0)
return true;
alert( "error ");
obj.select();
obj.focus();
return false;
}
</script>
<input type= "text " onChange= "javascript:return CheckNumber(this); ">

热点排行