<html>
<head>
<title>数当てゲーム</title>
<script language="JavaScript"><!--
n=Math.floor(Math.random()*10);
flag=false;
count=3;

function check(){
	if(flag==true){
		return;
	}
	ans=document.gform.Num.value;
	//if(n==ans){

	if(ans==""){
		alert("空白です");
		return;
	}

	if(ans==n){
		alert("正解です\n正解は"+ans+"でした");
		flag=true;

	}else if( (ans>=0) && (ans<=9) ){
		alert("不正解です");

	}else{
		alert("0〜9の値が入力されていません");
		return;
	}

	count=count-1;
	if(count== ""){
		alert("正解は"+n+"でした");
		flag=true;
	}
}

function res(){
	flag=false;
	count=3;
	n=Math.floor(Math.random()*10);

}

//--></script>
</head>
<body>
<form name="gform">
数値:<input type="text" name="Num"><br>
<input type="button" value="チェック" onClick="check()">
<input type="button" value="リセット" onClick="res()">

</from>
</body>
</html>

inserted by FC2 system