<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>userreg.html</title><meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8"><!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<link type="text/css" rel="stylesheet" href="../css/cssLogin.css" />
<SCRIPT language=javascript>
function regg()
{
var userID=document.zcform.username.value;//用户名
var userPwd=document.zcform.userPwd.value;//密码
var userPwdcmp=document.zcform.userPwd1.value;//确认密码
var email=document.zcform.txtemail.value;//email
var che=/\W/
if(userID.length<4 || userID.length>15)
{
alert("用户名必须在4-15位之间!");
document.zcform.username.select();
return false;
}
else if(che.test(userID))
{
alert("用户名必须为'_',字母,数字");
document.zcform.username.select();
return false;
}
else if(userPwd.length<5 || userPwd.length>16)
{
alert("密码必须在5-16位之间!");
document.zcform.userPwd.value="";
document.zcform.userPwd.select();
return false;
}
else if(userPwdcmp!=userPwd)
{
alert("两次密码不一致,请重新输入密码!");
document.zcform.userPwd.value="";
document.zcform.userPwd1.value="";
document.zcform.userPwd.select();
return false;
}
else if(userID==userPwd)
{
if(confirm("用户名和密码相同,密码要重置吗")==true)
{
document.zcform.userPwd.value="";
document.zcform.userPwd1.value="";
document.zcform.userPwd.select();
}
}
else if(email.indexOf("@",0)==-1)
{
alert("邮件格式不正确!必须包含@符号!");
document.zcform.txtemail.select();
return false;
}
else if(email.indexOf(".",0)==-1)
{
alert("邮件格式不正确!必须包含.符号!");
document.zcform.txtemail.select();
return false;
}
else if(email.indexOf("com",0)==-1)
{
alert("邮件格式不正确!必须包含com符号!");
document.zcform.txtemail.select();
return false;
}
if(confirm("您确认资料填写无误了吗\n确定继续,取消进行重置!")==true)
{
alert("恭喜你注册成功");
window.location.href="login.jsp";
return true;
}
}
</script>
</head> 
<body background="red">
<table id="tabBac">
<tr>
<td>
<form action="../servlet/inforegservlet" method="post" name="zcform">
<h3>新闻发布系统用户注册表单</h3>
<table id="tabLogin">
<tr>
<td align="right">用户名:</td>
<td>
<input type="text" name=username class="txtBorder">
</td>
</tr>
<tr>
<td align="right">密 码:</td>
<td>
<input type="password" name="userPwd" class="txtBorder">
</td>
</tr>
<tr>
<td align="right">确认密码:</td>
<td>
<input type="password" name="userPwd1" class="txtBorder">
</td>
</tr>
<tr>
<td align="right">电子邮件:</td>
<td>
<input type="text" name="txtemail" class="txtBorder">
</td>
</tr>
<tr>
<td>权限设置</td>
<td>
<select name="ismanager">
<option value="0" selected="selected">--普通管理员--</option>
</select>
</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" value="注 册" id="btnSubmit" onclick=" return regg()">
<input type="reset" value="重 置" id="btnReset">
</td>
</tr>
</table>
</form>
</td>
</tr>
</table> 
</body>
</html>
谢谢了!!!!!!!!!!!!!!!!!!

解决方案 »

  1.   

    document.zcform.username.select();
    zcform是你表单的名称
    username是zcform表单中的文本的名称
    意思是将表单中的文本选种
      

  2.   

    选中该文本框内的内容。
        [align=center]====  ====
    [/align]
      

  3.   

    <html>
    <head>
    <script type="text/javascript">
    function selectText()
    {
                    //选中文本框内容
    document.oFrom.otext.select();
            }
    </script>
    </head>
    <body>
    <form name="oFrom">
    <input type="text" id="otext" value="otext"/>
    <input type="button" onclick="selectText();"/>
    </form>
    </body>
    </html>