<!DOCTYPE html>
<html>
<head>
<title>login.html</title>
<title>登录</title>
<link rel="stylesheet" type="text/css" href="./CSS/login.css">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/htmlcharset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
</head>
<body>
<div id="container">
<h1 id="title">小菊花爱心书店</h1>
<div id="information">
<form action="first.html">
<div id="box">
账号:<input type="text" name="keyName">
<br>
密码:<input type="password" name="userPass">
<br>
<input id="B" class="button1" type="submit" name="buyer" value="login">
<br>
<a href="register.html">立即注册</a>
</div>
</form>
</div>
</div>
</body>
</html>
------------------------------------------------
css文件
------------------------------------------------
@CHARSET "GB2312"
body{
background-image:url(../img/login.jpg)
background-size: cover
margin: 0
padding: 0
}
#container{
height:500px
width:400px
background-color:#D2B571
border-radius: 10px
margin: 100px auto
position:relative
box-shadow:2px 2px 10px #888888
}
h1{
text-align: center
padding-top:50px
color: white
}
#information{
background-color: #F5F4F2
height: 350px
width:400px
position:absolute
margin-top: 10px
}
#box{
width:200px
margin-left: 100px
margin-top: 60px
}
input{
display: block
width: 200px
padding-top:5px
height:35px
border: 1.5px solid #eee
border-radius:10px
background-color:#F4F8FF
}
.button1 {
height:35px
margin-top: 20px
padding: 5px 15px
text-align: center
background-color: #F48951
color: white
border: 0px
border-radius:10px
box-shadow:2px 2px 10px #888888
}
.button1:hover {
background-color: white
color: #F48951
border: 1.5px solid #F48951
}
button{
width:90px
position:absolute
top:70px
}
button:hover {
width:90px
position:absolute
top:62px
}
1.首先我们新建一个带有button按钮的页面
<button type="submit" class="form-contrpl">注册</button>
2.button按钮不能直接添加herf属性,我们可以通过button的onClick事件来实现页面的跳转。
第一种方法:window.open()可以实现页面跳转。
第二种方法:给button的onClick一个触发事件
因为我们希望页面在点击登录按钮的时候实现页面跳转,所以函数是直接声明,而不是等页面加载完后立即执行的。
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html charset=utf-8">
<title>贵美商城</title>
<link rel="stylesheet" type="text/css" href="css/global.css">
<link rel="stylesheet" type="text/css" href="css/layout.css">
<script type="text/javascript">
// snameCheck() && passCheck()
function validateform(){
if(snameCheck() && passCheck())
return true
else
return false
}
// Screen Name Validation
function snameCheck(){
var sname = document.getElementsByName("sname")[0].value
var illegalChars = /\W/
if(sname.length != 0){
if(illegalChars.test(sname)){
document.getElementById("passMsg").innerHTML.replace(/'会员名无效'/,'')
document.getElementById("passMsg").innerHTML='会员名无效'
document.getElementsByName("sname")[0].select()
return false
}
}
else
{
document.getElementById("userMsg").innerHTML.replace(/'是否忘记输入会员名?'/,'')
document.getElementById("userMsg").innerHTML='是否忘记输入会员名?'
document.getElementsByName("sname")[0].focus()
return false
}
if(sname!=="zhangsan"){ //验证会员名必须为张三
document.getElementById("userMsg").innerHTML.replace(/'是否输入的会员名有错?'/,'')
document.getElementById("userMsg").innerHTML='是否输入的会员名有错?'
document.getElementsByName("sname")[0].focus()
return false
}
return true
}
function passCheck(){
var userpass = document.getElementsByName("pass")[0].value
var illegalChars = /[\W_]/// allow only charactors and numbers
// Check if Password field is blank.
if(userpass == ""){
document.getElementById("passMsg").innerHTML.replace(/'未输入密码 \n" + "请输入密码'/,'')
document.getElementById("passMsg").innerHTML='未输入密码 \n" + "请输入密码'
document.getElementsByName("pass")[0].focus()
return false
}
// Check if password length is less than 6 charactor.
if(userpass.length < 6){
document.getElementById("passMsg").innerHTML.replace(/'密码必须多于或等于 6 个字符。\n'/,'')
document.getElementById("passMsg").innerHTML='密码必须多于或等于 6 个字符。\n'
document.getElementsByName("pass")[0].focus()
return false
}
//check if password contain illigal charactors.
else if(illegalChars.test(userpass)){
document.getElementById("passMsg").innerHTML.replace(/'密码包含非法字符'/,'')
document.getElementById("passMsg").innerHTML='密码包含非法字符'
document.getElementsByName("pass")[0].select()
return false
}
if(userpass!=="123456"){ //验证密码必须为123456
document.getElementById("passMsg").innerHTML.replace(/'密码错误,请重新输入!'/,'')
document.getElementById("passMsg").innerHTML='密码错误,请重新输入!'
document.getElementsByName("pass")[0].focus()
return false
}
return true
}
</script>
<script type="text/javascript" charset="utf-8" src="http://cdn.gwdang.com/js/gwdang-notifier-bdext.js"></script></head>
<body>
<div id="container">
<iframe id="header" src="header.htm" width="980" height="136" frameborder="0" scrolling="no"></iframe>
<form action="login_success" method="post">
<div class="login">
<ul class="form f_l">
<h1><img src="images/logintitle.gif" alt="会员登录"></h1>
<li class="login_list"><label>会员名:</label><input type="text" name="login">(可包含 a-z、0-9 和下划线)</li>
<li class="login_list"><label>密&nbsp&nbsp&nbsp码:</label><input type="text" name="pwd">(至少包含 6 个字符)</li>
<li class="a_c"><img src="images/login.gif" alt="登录"></li>
<li class="desc">δ&nbsp&nbsp<a href="#">什么是安全登录</a>。</li>
<li class="desc">δ&nbsp&nbsp香港会员(繁体中文用户)由此<a href="#">登入</a></li>
<li class="desc">δ&nbsp&nbsp<a href="#">密码安全贴士</a>。</li>
<li class="desc">δ&nbsp&nbsp防止病毒或者木马窃取您的账户信息,<a href="#">在线检查</a>您的电脑是否安全。</li>
</ul>
<h1><img src="images/register.gif" alt="注册会员"></h1>
<ul class="aside f_l">
<li class="regpic"><span>便宜有好货!</span>超过7000万件商品任您选。</li>
<li class="regpic regpic2"><span>买卖更安全!</span>交易超安全。</li>
<li class="regpic regpic3"><span>免费开网店!</span>轻松赚钱交友。</li>
<li class="regpic regpic4"><span>超人气社区!</span>彩活动每一天</li>
<li class="a_c"><a href="#"><img src="images/registernow.gif" alt="现在就注册"></a></li>
<ul class="reged">
<li class="regpic regpic5">您已经是会员?<a href="#">由此登入</a></li>
<li class="regpic regpic6">繁体中文用户由此<a href="#">注册</a></li>
</ul>
</ul>
</div>
</form>
<iframe id="footer" src="footer.htm" width="980" height="136" frameborder="0" scrolling="no"></iframe>
</div> <!--container end-->
<div class="_bd_ext_tip" style="visibility: hidden"><span class="_bd_ext_search">百度一下</span><span class="_bd_ext_open">打开链接</span><span class="_bd_ext_copy">复制</span></div></body></html>