我對JavaScript很陌生,我想做一個輸入檢查。 這裏是我的腳本:這個數字腳本有什麼問題?
function checkInp()
{
var x=document.forms["myForm"]["num"].value; // Get the value
if (isNaN(x))
{
alert("Not a number!"); // Check if the input is a number
return false;
}
var valuex=document.forms["myForm"]["num"].value; // Get the value, i don't know if i have to re-write this variable, if no, please comment.
Number(valuex); // Make the input a number
if (valuex.value > 480) {
alert("Too high!"); // See if the number is greater than 480. If yes, say that, if not, return normally.
return false;
}
else {
return;
}
}
我不知道發生了什麼,但自從我加入了第二部分的腳本不工作(檢查,如果數大於480)。
請幫助我,如果可能,請用完整示例。
你爲什麼要否決?有理由嗎? – MucaP