主题:为什么会提示“错误: 缺少对象”
刚刚学了点javascript,照着别人的东西自己改了一个测试用户名的程序,但是一运行就报错,提示“错误: 缺少对象”(粉色的那一行),自己怎么看都不知道问题所在,希望高手能帮忙看看错在哪里,还有就是再帮我看看这个程序还有没有其他错误,谢谢了
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript" language="javascript">
var profile_username_toolong = '对不起,您的用户名超过 15 个字符,请输入一个较短的用户名。';
var profile_username_tooshort = '对不起,您输入的用户名小于4个字符, 请输入一个较长的用户名。';
var profile_username_illegal = '用户名包含敏感字符或被系统屏蔽,注意用户名只能使用英文和数字,请重新填写。';
function checkusername() {
[color=FF00FF]var username = getElementById("username").value;[/color]username = trim(username)
if(username == lastusername) {
return;
} else {
lastusername = username;
}
var cu = getElementById("checkusername");
var unlen = username.replace(/[^\x00-\xff]/g, "**").length;
if (username == '' || /^[a-zA-Z0-9_]+$/.test('username')!="ture"){
warning(cu, profile_username_illegal);
}else{
return;
if(unlen < 4 || unlen > 15) {
warning(cu, unlen < 4 ? profile_username_tooshort : profile_username_toolong);
return;
}
}
}
</script>
</head>
<body>
<form name="reg" method="post" action="freg.asp">
<table cellspacing="0" cellpadding="4" width="598" align="center">
<!--DWLayoutTable-->
<tr>
<td bgcolor="#D2DBE2" colspan="2" class="color1"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td width="70" class="text1" >用户名:</td>
<td width="482" class="text1">
<div style="width:100"><input type="text" name="username" size="25" maxlength="15" id="username" class="input" onBlur="checkusername()"></div>
<div id="checkusername"></div>
</td>
</tr>
</table>
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript" language="javascript">
var profile_username_toolong = '对不起,您的用户名超过 15 个字符,请输入一个较短的用户名。';
var profile_username_tooshort = '对不起,您输入的用户名小于4个字符, 请输入一个较长的用户名。';
var profile_username_illegal = '用户名包含敏感字符或被系统屏蔽,注意用户名只能使用英文和数字,请重新填写。';
function checkusername() {
[color=FF00FF]var username = getElementById("username").value;[/color]username = trim(username)
if(username == lastusername) {
return;
} else {
lastusername = username;
}
var cu = getElementById("checkusername");
var unlen = username.replace(/[^\x00-\xff]/g, "**").length;
if (username == '' || /^[a-zA-Z0-9_]+$/.test('username')!="ture"){
warning(cu, profile_username_illegal);
}else{
return;
if(unlen < 4 || unlen > 15) {
warning(cu, unlen < 4 ? profile_username_tooshort : profile_username_toolong);
return;
}
}
}
</script>
</head>
<body>
<form name="reg" method="post" action="freg.asp">
<table cellspacing="0" cellpadding="4" width="598" align="center">
<!--DWLayoutTable-->
<tr>
<td bgcolor="#D2DBE2" colspan="2" class="color1"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td width="70" class="text1" >用户名:</td>
<td width="482" class="text1">
<div style="width:100"><input type="text" name="username" size="25" maxlength="15" id="username" class="input" onBlur="checkusername()"></div>
<div id="checkusername"></div>
</td>
</tr>
</table>
</form>
</body>
</html>