1
2號我目前使用的谷歌地圖和嘗試使用輸入驗證之間。我要求用戶使用0到20之間的數字作爲放大位置。驗證輸入是在JavaScript
下面是我使用的代碼。第一if
聲明完全適用於任何數量超過20,但是當我使用數字如0和-1修復這個第二不起作用(例如)
有什麼建議?
function inputIsValid() {
console.log("Inside inputIsValid function");
//Check for Above 20
if (document.getElementById("txtZoom").value > 20) {
alert("Please insertAmount between 0 and 20");
document.getElementById("txtZoom").focus();
return false;
//Check for Number below 0
if (document.getElementById("txtZoom").value < 0) {
alert("Please insertAmount between 0 and 20");
document.getElementById("txtZoom").focus();
return false;
}
}
}
Gahhhhh這樣的菜鳥錯誤!猜猜有時候你只需要第二組眼睛。謝謝!併爲這個愚蠢的錯誤感到抱歉!將接受答案的時候能夠 – Andrew 2012-07-23 00:24:36
沒問題,它長編碼會話後,特別是發生了。我也清理了一些代碼,因爲原來只是一個複製粘貼。 – theabraham 2012-07-23 00:26:44
是的,看起來好多了! – Andrew 2012-07-23 00:27:36