HTML注册页面代码

HTML注册页面代码

<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Untitled Document</title> 
<script language="javascript"> 
function checkname(){ 
var div = document.getElementById("div1"); 
div.innerHTML = ""; 
var name1 = document.form1.text1.value; 
if (name1 == "") { 
div.innerHTML = "姓名不能为空!"; 
document.form1.text1.focus(); 
return false; 

if (name1.length < 4 || name1.length > 16) { 
div.innerHTML = "姓名输入的长度4-16个字符!"; 
document.form1.text1.select(); 
return false; 

var charname1 = name1.toLowerCase(); 
for (var i = 0; i < name1.length; i++) { 
var charname = charname1.charAt(i); 
if (!(charname >= 0 && charname <= 9) && (!(charname >= 'a' && charname <= 'z')) && (charname != '_')) { 
div.innerHTML = "姓名包含非法字母,只能包含字母,数字,和下划线"; 
document.form1.text1.select(); 
return false; 


return true;

}

function checkpassword(){ 
var div = document.getElementById("div2"); 
div.innerHTML = ""; 
var password = document.form1.text2.value; 
if (password == "") { 
div.innerHTML = "密码不位空!"; 
document.form1.text2.focus(); 
return false; 

if (password.length < 4 || password.length > 12) { 
div.innerHTML = "密码长度4-12位"; 
document.form1.text2.select(); 
return false; 

return true; 
}

function checkrepassword(){ 
var div = document.getElementById("div3"); 
div.innerHTML = ""; 
var password = document.form1.text2.value; 
var repass = document.form1.text3.value; 
if (repass == "") { 
div.innerHTML = "密码不位空!"; 
document.form1.text3.focus(); 
return false; 

if (password != repass) { 
div.innerHTML = "输入密码和确认密码长度不一致"; 
document.form1.text3.select(); 
return false; 

return true; 
}

function checkEmail(){ 
var div = document.getElementById("div4"); 
div.innerHTML = ""; 
var email = document.form1.text5.value; 
var sw = email.indexOf("@", 0); 
var sw1 = email.indexOf(".", 0); 
var tt = sw1 - sw; 
if (email.length == 0) { 
div.innerHTML = "电子邮件不能位空"; 
document.form1.text5.focus(); 
return false; 

if (email.indexOf("@", 0) == -1) { 
div.innerHTML = "电子邮件格式不正确,必须包含@符号!"; 
document.form1.text5.select(); 
return false; 

if (email.indexOf(".", 0) == -1) { 
div.innerHTML = "电子邮件格式不正确,必须包含.符号!"; 
document.form1.text5.select(); 
return false; 

if (tt == 1) { 
div.innerHTML = "邮件格式不对。@和.不可以挨着!"; 
document.form1.text5.select(); 
return false; 

if (sw > sw1) { 
div.innerHTML = "电子邮件格式不正确,@符号必须在.之前"; 
document.form1.text5.select(); 
return false; 

else { 
return true; 
}

return ture; 
}

function check(){ 
if (checkname() && checkpassword() && checkrepassword() && checkEmail()) { 
return true; 

else { 
return false; 


</script> 
</head> 
<body> 
<form name="form1" method="post" action="2.html" οnsubmit="return check()"> 
<table> 
<tr> 
<td> 
用户名: 
</td> 
<td> 
<input id="text1" type="text" name="text1" οnblur="check()"> 
<div id="div1" style="display:inline"> 
</div> 
</td> 
</tr> 
<tr> 
<td> 
密码: 
</td> 
<td> 
<input id="text2" type="password" name="text2" οnblur="check()"> 
<div id="div2" style="display:inline"> 
</div> 
</td> 
</tr> 
<tr> 
<td> 
确认密码: 
</td> 
<td> 
<input id="text3" type="password" name="text3" οnblur="check()"> 
<div id="div3" style="display:inline"> 
</div> 
</td> 
</tr> 
<tr> 
<td> 
电子邮件地址: 
</td> 
<td> 
<input id="text4" type="text" name="text4" οnblur="check()"> 
<div id="div4" style="display:inline"> 
</div> 
</td> 
</tr> 
<tr align="center"> 
<td align="center"> 
<input type="submit" value="提交" name="tect6"><input type="reset" value="重置" name="text7"> 
</td> 
</tr> 
</table> 
</form> 
</body> 
</html>

  • 9
    点赞
  • 40
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的HTML登录注册页面的制作代码: ```html <!DOCTYPE html> <html> <head> <title>Login/Register Page</title> <style> body { font-family: Arial, sans-serif; background-color: #f4f4f4; } .container { max-width: 400px; margin: 0 auto; padding: 20px; background-color: #fff; border-radius: 5px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } h2 { text-align: center; } input[type="text"], input[type="password"] { width: 100%; padding: 10px; margin-bottom: 10px; border: 1px solid #ccc; border-radius: 4px; } input[type="submit"] { width: 100%; padding: 10px; background-color: #4CAF50; color: #fff; border: none; border-radius: 4px; cursor: pointer; } input[type="submit"]:hover { background-color: #45a049; } </style> </head> <body> <div class="container"> <h2>Login</h2> <form> <input type="text" placeholder="Username" required> <input type="password" placeholder="Password" required> <input type="submit" value="Login"> </form> </div> <div class="container"> <h2>Register</h2> <form> <input type="text" placeholder="Username" required> <input type="password" placeholder="Password" required> <input type="password" placeholder="Confirm Password" required> <input type="submit" value="Register"> </form> </div> </body> </html> ``` 这段代码创建了一个简单的登录注册页面,包含一个登录表单和一个注册表单。用户可以在登录表单中输入用户名和密码,然后点击登录按钮进行登录。在注册表单中,用户需要输入用户名、密码和确认密码,然后点击注册按钮进行注册

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值