<html>
<head>
<script language=vbscript>
function a()
if instr(document.genForm.aa.value,".")>0 then
   msgbox "小鬼,别乱来!"
else
   msgbox "恭喜你!成功了!"
end if
end function
</script>
</head>
<body>
<form name=genForm method=post >
<br>请输入想要的个数:<input type=text name=v id=aa>(禁止小数)
<br><input type=button value=OK onclick="a()">
</form>
</body>
</html>

解决方案 »

  1.   

    <html>
    <head>
    <script language=javascript>
    function a()
    {
    if(document.genForm.aa.value.search(/\./)!==-1)
       alert ("不能输入小数哦!");
    else
       alert ("恭喜你!成功了!");
    }
    </script>
    </head>
    <body>
    <form name=genForm method=post >
    <br>请输入想要的个数:<input type=text name=v id=aa>(禁止小数)
    <br><input type=button value=OK onclick="a()">
    </form>
    </body>
    </html>