2019/0219/Javascript終極密碼&musicplay&asp.net驗證器
js
應用1 終極密碼
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<script>
//終極密碼
var pass = Math.floor((Math.random() * 99) + 1); //隨機產生1~99
//document.write(pass);
var intMax = 100, intMin = 0;
while (true) {
pwd = prompt("終極密碼" + intMin + "-" + intMax + ":", "");
//alert(pwd);
if (pwd == null) {
alert("您取消遊戲!!");
break;
}
if (pwd-0 >= intMax || pwd-0 <= intMin || isNaN(pwd) || pwd.indexOf(".")!=-1) {
alert("請輸入範圍內的值!!");
continue;
}
if (pass == pwd) {
alert("猜對了");
break;
}
else if (pass > pwd) {
//alert("猜錯了");
intMin = pwd;
}
else if (pass < pwd) {
//alert("猜錯了");
intMax = pwd;
}
}
</script>
</body>
</html>應用2 musicplay

asp驗證器
RangeValidator
不只是數字也可以套用在日期
RegularExpressionValidator
驗證相關聯之輸入控制項的值,是否符合規則運算式指定的模式。


CustomValidator
自訂規則驗證器


偵錯 中斷點

Last updated
