<script type="text/javascript">
var a = Math.ceil(Math.random() * 10);
var b = Math.ceil(Math.random() * 10);
var c = a b
function DrawBotBoot()
{
document.write("What is " a " " b "? ");
document.write("<input id='BotBootInput' type='text' maxlength='2' size='2'/>");
}
function ValidBotBoot(){
var d = document.getElementById('BotBootInput').value;
if (d == c) return true;
return false;
}
</script>
</head>
<body>
<script type="text/javascript">DrawBotBoot()</script>
<input id="Button1" type="button" value="Check" onclick="alert(ValidBotBoot());"/>
โค๊ดด้านบนเทสเเล้วใช้ได้
คือ ถ้าใส่เลขถูกมันจะโชว์ป๊อปอัพว่า ถูก
แล้วเวลาใช้งาน เอาไปใส่ยังไงของหน้า form เหรอครับ