怎么用Macromedia Dreamweaver 8做一个登录页面
求个教程或者大概说一下....悲剧啊`我新手用户可以填写,要求能验证完成输入信息的验证工作:1.用户名,只能由字母、数字和下划线组成,且首字符不能为数字;2.密码,要求在...
求个教程或者大概说一下....悲剧啊`我新手
用户可以填写,要求能验证完成输入信息的验证工作:
1. 用户名,只能由字母、数字和下划线组成,且首字符不能为数字;
2. 密码,要求在6到15位之间;
3. 确认密码,必须和密码一致;
如果不符合以上要求,分别给出相关提示信息。如果都符合则响应打开一个新的网页。
写出主要代码和运行的截图(各种情况的,比如用户名不合格的,合格的 ,密码合格和不合格的,确认密码和密码一致以及不一致的等所有情况) 展开
用户可以填写,要求能验证完成输入信息的验证工作:
1. 用户名,只能由字母、数字和下划线组成,且首字符不能为数字;
2. 密码,要求在6到15位之间;
3. 确认密码,必须和密码一致;
如果不符合以上要求,分别给出相关提示信息。如果都符合则响应打开一个新的网页。
写出主要代码和运行的截图(各种情况的,比如用户名不合格的,合格的 ,密码合格和不合格的,确认密码和密码一致以及不一致的等所有情况) 展开
展开全部
<!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=utf-8" />
<title>无标题文档</title>
<script language="javascript" type="text/javascript">
function checkName(){
var name = document.getElementById("name").value;
if (name != ""){
for(var i = 0;i<name.length;i++){
if (name.charAt(i) >= 'a' && name.charAt(i) <= 'z' || name.charAt(i) >= 0 && name.charAt(i) <= 9 || name.charAt(i) =="_"){
document.getElementById("ename").style.display = "none";
}else {
document.getElementById("ename").style.display = "inline";
document.getElementById("ename").innerHTML = "<font color='red'>用户名格式不正确!</font>";
document.getElementById("name").focus();
document.getElementById("name").select();
}
}
}
else {
document.getElementById("ename").style.display = "inline";
document.getElementById("ename").innerHTML = "<font color='red'>请输入用户名!</font>";
document.getElementById("name").focus();
document.getElementById("name").select();
}
}
function checkPWD(){
var pwd = document.getElementById("pwd").value;
var rePwd = document.getElementById("rePwd").value;
if (pwd != "" && rePwd != ""){
if (pwd.length >= 6 && pwd.length <= 12 || rePwd.length >= 6 && rePwd.length <= 12){
if (pwd == rePwd){
document.getElementById("epwd").style.display ="none";
}
else {
document.getElementById("epwd").style.display = "inline";
document.getElementById("epwd").innerHTML = "<font color='red'>两次密码输入不相同。</font>";
}
}
else {
document.getElementById("epwd").style.display = "inline";
document.getElementById("epwd").innerHTML = "<font color='red'>密码格式不正确。</font>";
}
}
else {
document.getElementById("epwd").style.display = "inline";
document.getElementById("epwd").innerHTML = "<font color='red'>请输入完整的密码。</font>";
}
}
function checkEmail(){
var rex = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
var email = document.getElementById("mail").value;
if (email != ""){
if (rex.test(email)){
document.getElementById("email").style.display = "none";
}
else {
document.getElementById("email").style.display = "inline";
document.getElementById("email").innerHTML = "<font color='red'>请输入正确的电子邮箱地址。</font>"
document.getElementById("mail").focus();
document.getElementById("mail").select();
}
}
else {
document.getElementById("email").style.display = "inline";
document.getElementById("email").innerHTML = "<font color='red'>请输入电子邮箱地址。</font>"
document.getElementById("mail").focus();
document.getElementById("mail").select();
}
}
function changeFocus(){
if (event.keyCode == 13 && event.srcElement.type == "text"){
event.keyCode = 9;
}
}
document.onkeydown = changeFocus;
</script>
</head>
<body style="font-size:12px">
<form action="#" method="post" name="myForm">
<table border="0">
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td width="138">用户名:</td>
<td width="193"><input type="text" name="name" id="name" onblur="checkName()"/></td>
<td width="323"><div id="ename" style="display:none"></div>
只能输入字母或数字,4-16个字符</td>
</tr>
<tr>
<td>密码:</td>
<td><input type="text" name="pwd" id="pwd"/></td>
<td><div id="epwd" style="display:none"></div>
密码长度6-12位</td>
</tr>
<tr>
<td>确认密码:</td>
<td><input type="text" name="rePwd" id="rePwd" onblur="checkPWD()"/></td>
<td> </td>
</tr>
<tr>
<td>电子邮箱地址:</td>
<td><input type="text" name="mail" id="mail" onblur="checkEmail()"/></td>
<td><div id="email" style="display:none"></div>
请输入正确的邮箱地址</td>
</tr>
<tr>
<td> </td>
<td align="center"><input type="reset" name="re" id="re" value="重新填写" /></td>
<td><input type="submit" name="button" id="button" value="同意以下协议条款并提交" /></td>
</tr>
<tr>
<td colspan="3"><textarea name="textarea" id="textarea" cols="80" rows="10">123123</textarea></td>
</tr>
</table>
</form>
</body>
</html>
代码在这里,我刚刚做好就看到你要了。。=.=
用户名首位不能为数字:
if (!(name.charAt(0) >=0 && name.charAt(0) <= 9)){
......
}
在每个函数后面写上return true;如果不符合条件,就return false;
再写个checkAll()函数,对所有函数的返回值判断,全部通过就return true;
最后在提交时,在<form>里面加上onsubmit(return checkAll())
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="javascript" type="text/javascript">
function checkName(){
var name = document.getElementById("name").value;
if (name != ""){
for(var i = 0;i<name.length;i++){
if (name.charAt(i) >= 'a' && name.charAt(i) <= 'z' || name.charAt(i) >= 0 && name.charAt(i) <= 9 || name.charAt(i) =="_"){
document.getElementById("ename").style.display = "none";
}else {
document.getElementById("ename").style.display = "inline";
document.getElementById("ename").innerHTML = "<font color='red'>用户名格式不正确!</font>";
document.getElementById("name").focus();
document.getElementById("name").select();
}
}
}
else {
document.getElementById("ename").style.display = "inline";
document.getElementById("ename").innerHTML = "<font color='red'>请输入用户名!</font>";
document.getElementById("name").focus();
document.getElementById("name").select();
}
}
function checkPWD(){
var pwd = document.getElementById("pwd").value;
var rePwd = document.getElementById("rePwd").value;
if (pwd != "" && rePwd != ""){
if (pwd.length >= 6 && pwd.length <= 12 || rePwd.length >= 6 && rePwd.length <= 12){
if (pwd == rePwd){
document.getElementById("epwd").style.display ="none";
}
else {
document.getElementById("epwd").style.display = "inline";
document.getElementById("epwd").innerHTML = "<font color='red'>两次密码输入不相同。</font>";
}
}
else {
document.getElementById("epwd").style.display = "inline";
document.getElementById("epwd").innerHTML = "<font color='red'>密码格式不正确。</font>";
}
}
else {
document.getElementById("epwd").style.display = "inline";
document.getElementById("epwd").innerHTML = "<font color='red'>请输入完整的密码。</font>";
}
}
function checkEmail(){
var rex = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
var email = document.getElementById("mail").value;
if (email != ""){
if (rex.test(email)){
document.getElementById("email").style.display = "none";
}
else {
document.getElementById("email").style.display = "inline";
document.getElementById("email").innerHTML = "<font color='red'>请输入正确的电子邮箱地址。</font>"
document.getElementById("mail").focus();
document.getElementById("mail").select();
}
}
else {
document.getElementById("email").style.display = "inline";
document.getElementById("email").innerHTML = "<font color='red'>请输入电子邮箱地址。</font>"
document.getElementById("mail").focus();
document.getElementById("mail").select();
}
}
function changeFocus(){
if (event.keyCode == 13 && event.srcElement.type == "text"){
event.keyCode = 9;
}
}
document.onkeydown = changeFocus;
</script>
</head>
<body style="font-size:12px">
<form action="#" method="post" name="myForm">
<table border="0">
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td width="138">用户名:</td>
<td width="193"><input type="text" name="name" id="name" onblur="checkName()"/></td>
<td width="323"><div id="ename" style="display:none"></div>
只能输入字母或数字,4-16个字符</td>
</tr>
<tr>
<td>密码:</td>
<td><input type="text" name="pwd" id="pwd"/></td>
<td><div id="epwd" style="display:none"></div>
密码长度6-12位</td>
</tr>
<tr>
<td>确认密码:</td>
<td><input type="text" name="rePwd" id="rePwd" onblur="checkPWD()"/></td>
<td> </td>
</tr>
<tr>
<td>电子邮箱地址:</td>
<td><input type="text" name="mail" id="mail" onblur="checkEmail()"/></td>
<td><div id="email" style="display:none"></div>
请输入正确的邮箱地址</td>
</tr>
<tr>
<td> </td>
<td align="center"><input type="reset" name="re" id="re" value="重新填写" /></td>
<td><input type="submit" name="button" id="button" value="同意以下协议条款并提交" /></td>
</tr>
<tr>
<td colspan="3"><textarea name="textarea" id="textarea" cols="80" rows="10">123123</textarea></td>
</tr>
</table>
</form>
</body>
</html>
代码在这里,我刚刚做好就看到你要了。。=.=
用户名首位不能为数字:
if (!(name.charAt(0) >=0 && name.charAt(0) <= 9)){
......
}
在每个函数后面写上return true;如果不符合条件,就return false;
再写个checkAll()函数,对所有函数的返回值判断,全部通过就return true;
最后在提交时,在<form>里面加上onsubmit(return checkAll())
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询