【发布时间】:2012-04-30 07:38:36
【问题描述】:
我在做一个asp.net网页,有一个texbox,我想确保输入的文本少于3个字符,我写的代码是
<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 运行时错误:无法获取属性‘值’的值:对象为空或未定义”,每当我输入某些内容时,我都不知道出了什么问题,因为我真的是新手asp.net,甚至不确定我的代码是否真的可以工作,希望有人可以帮助我,非常感谢
【问题讨论】: