日期:2014-05-16  浏览次数:20744 次

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); ">