以下程序接受4個輸入,並且如果所有4個輸入都是數字,則程序應按順序對數字進行排序,否則(例如,如果輸入是字母表),它應顯示無效輸入。Jscript - 檢查非數字輸入
目前,它顯示無效輸入,輸入不論什麼I型
可能有人幫助請只數,?
<!DOCTYPE html>
<html>
<body>
<input id="num1" type="number">
<input id="num2" type="number">
<input id="num3" type="number">
<input id="num4" type="number">
<button type="button" onclick= "Val()">Submit</button>
<p id="sort">
SORTED NUMBERS ARE
</p>
<script>
function Val()
{
int a, b, c, d, e;
var text;
a = document.getElementById ("num1").value;
b = document.getElementById ("num2").value;
c = document.getElementById ("num3").value;
d = document.getElementById ("num4").value;
if (isNaN(a)||isNaN(b)||isNaN(c)||isNaN(d))
{
text = "Invalid Entry";
document.getElementById("sort").innerHTML = text;
window.alert ("ENTER ONLY NUMBERS");
//return false;
}
else
{
e = [a,b,c,d];
e.sort();
document.getElementById("sort").innerHTML = e;
window.alert ("SORTED");
}
}
</script>
</body>
</html>
什麼是'詮釋A,B,C,d,E;'? – Vidul