怎么設(shè)定,如果輸入其他字符會(huì)報(bào)錯(cuò)呢?就是文本框只能輸入0-100。
怎么設(shè)定,如果輸入其他字符會(huì)報(bào)錯(cuò)呢?就是文本框只能輸入0-100。
怎么設(shè)定,如果輸入其他字符會(huì)報(bào)錯(cuò)呢?就是文本框只能輸入0-100。
怎么設(shè)定,如果輸入其他字符會(huì)報(bào)錯(cuò)呢?就是文本框只能輸入0-100。
怎么設(shè)定,如果輸入其他字符會(huì)報(bào)錯(cuò)呢?就是文本框只能輸入0-100。
2018-12-11
舉報(bào)
2018-12-12
再加一個(gè)判斷,你自己想一下這個(gè)判斷改怎么寫(xiě)。。
2019-02-16
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>prompt</title>
? <script type="text/javascript">
? function rec(){
var score; //score變量,用來(lái)存儲(chǔ)用戶(hù)輸入的成績(jī)值。
score = prompt("請(qǐng)輸入你的成績(jī)(0~100之間)");? ? ? ? ? ? ? ?;
if(score>=90 && score<=100)
{
? ?document.write("你很棒!");
}
else if(score>=75&&score<90)
? ? {
? ?document.write("不錯(cuò)吆!");
}
else if(score>=60&&score<75)
? ? {
? ?document.write("要加油!");
? ? }
??
else if(score>=0 && score<60)
? ? {
? ? ? ?document.write("要努力了!");
? ? }
?else
? ? {
? ? ? ?document.write("您輸入的有誤,請(qǐng)重新輸入!")
? ? }
? }
? </script>
</head>
<body>
? ? <input name="button" type="button" onClick="rec()" value="點(diǎn)擊我,對(duì)成績(jī)做評(píng)價(jià)!" />
</body>
</html>
2019-01-14
小改了下
<script>
? function rec(){
var score= prompt("請(qǐng)輸入")? ; //score變量,用來(lái)存儲(chǔ)用戶(hù)輸入的成績(jī)值。
if(isNaN(score)||score=="")
{
alert("input error!");
? ? ? ? rec();
}
? ? if(score>100||score<0)
? ? {
? ? ? ?alert("input error!");
? ? ? ? rec();
? ? }
else if(score>=90)
{
? ?document.write("你很棒!");
}
else if(score>=75)?
? ? {
? ?document.write("不錯(cuò)吆!");
}
else if(score>=60)
? ? {
? ?document.write("要加油!");
? ? }
? ? else if(score<60&&score>=0)?
{
? ? ? ?document.write("要努力了!");
}
? }
? </script>
2019-01-04
function rec(){
var score; //score變量,用來(lái)存儲(chǔ)用戶(hù)輸入的成績(jī)值。
score =? ?prompt("請(qǐng)輸入成績(jī):")? ? ;
var veget = /^(1|([1-9]\d{0,1})|100)$/;
???? if(!veget.test(score)){
???? ? ? alert("請(qǐng)輸入正確成績(jī)!");
???? }else{
???? ????if(score>=90){
???? ? ?????document.write("你很棒!");
???? ????}
???? ????else if(score>=75){
???? ? ?????document.write("不錯(cuò)吆!");
???? ????}
???? ????else if(score>=60){
???? ????? ?document.write("要加油!");
????? ? }
????? ? else{
????? ? ? ?document.write("要努力了!");
???? ????}
???? }
? }