用户名文本框中无法获得焦点的问题
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
function abc()
{
if(form1.textfield.value=="")
{
window.alert("用户名不能为空!");
form1.textfield.focus();
}
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="263" height="121" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="70">用户名:</td>
<td width="168"><label>
<input type="text" name="textfield" />
</label></td>
</tr>
<tr>
<td>密 码:</td>
<td><label>
<input type="text" name="textfield2" />
</label></td>
</tr>
<tr>
<td colspan="2"><label>
<div align="center">
<input type="submit" name="Submit" value="提交" onclick="abc()" />
<input type="submit" name="Submit2" value="清空" />
</div>
</label></td>
</tr>
</table>
</form>
</body>
</html>
代码如上所示,当用户名为空时,点击提交按钮后,无法在用户名的文本框中获得焦点,还请各位大侠指点一二!!
搜索更多相关主题的帖子:
焦点