我正在一個asp.net web頁面上,有一個texbox,我要確保輸入的文本是少於3個字符,我寫的代碼是微軟JScript運行時錯誤:無法獲得屬性「價值」的價值:對象爲空或未定義
<input type="text" name="searchcatid" size="15" onblur="test_length(Index.searchchatid)" />
<script>
function test_length(testcontrol) {
var teststring = testcontrol.value;
if (teststring.length >= 3) {
alert("ID must be 3 or fewer characters!");
testcontrol.focus();
}
else {
}
}
</script>
,我得到的錯誤「Microsoft JScript運行錯誤:無法獲得屬性‘價值’的價值:對象爲null或undefined」,每當我輸入的東西,我不知道哪裏出了問題,因爲即時通訊在asp.net真正的新,甚至不知道我的代碼將實際工作,希望有人能夠幫助我,非常感謝