我对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