您的位置:首页 > 其它

表单校验 点击登陆按钮的时候,触发验证

2017-05-03 14:37 302 查看
<title>休闲网登录页面</title>

<script type="text/javascript" src="js/jquery-1.11.1.js"></script>

<style type="text/css">
* {
padding: 0;
margin: 0;
}

body {
font-size: 12px;
color: #000;
line-height: 25px;
}

.main {
float: none;
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
clear: both;
}

#header {
background-image: url(./images/bg.gif);
background-repeat: repeat-x;
height: 36px;
}

#headerLeft {
width: 200px;
float: left;
}

#headerRight {
width: 160px;
float: right;
color: #FFF;
}

#center {
width: 362px;
text-align: center;
margin-top: 20px;
margin-right: auto;
margin-bottom: 20px;
margin-left: auto;
}

.bg {
background-image: url(图片/dl_l_bg.gif);
background-repeat: repeat-y;
}

.inputs {
width: 110px;
height: 16px;
border: solid 1px #666666;
}

.bold {
font-size: 18px;
font-weight: bold;
text-align: center;
line-height: 45px;
height: 40px;
}

.rb1 {
height: 20x;
color: #fff;
font-size: 13px;
background: #d32c47;
padding: 3px 10px;
border-left: 1px solid #fff;
border-top: 1px solid #fff;
border-right: 1px solid #6a6a6a;
border-bottom: 1px solid #6a6a6a;
cursor: pointer;
}

#footer {
text-align: center;
color: #333;
line-height: 35px;
}

#footer a {
color: #333;
text-decoration: underline;
}

#footer hover {
color: #333;
text-decoration: none;
}
</style>

<script type="text/javascript">
//第一步;当我点击登录按钮的时候,提交表单,也就是将表单中打有name属性的标签的value值提交到表单
function checkEmail(){

var flag=true;
//1.锁定对象
var dom=$("[id=email]"); //yymqqc@126.com

//2.判定是否包含@ 和.
var value=dom.val();
if(value.indexOf("@")==-1){
alert('邮箱中必须包含@');
flag=false;
}

if(value.indexOf(".")==-1){
alert('邮箱中必须包含.');
flag=false;
}
return flag;
}

$(function(){
var myform=$("form");
myform.submit(function(){
return checkEmail();
});
});

</script>

</script>

<body>
<div id="header" class="main">
<div id="headerLeft">
<img src="图片/logo.gif" />
</div>
<div id="headerRight">注册 | 登录 | 帮助</div>
</div>
<div class="main">
<table id="center" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="图片/dl_l_t.gif" /></td>
</tr>
<tr>
<td class="bg">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="bold">登录休闲网</td>
</tr>
<form action="day08shangke2.html" method="post" id="myform"	name="myform">
<tr>
<td>Email:<input id="email" type="text" name="email"
class="inputs" /></td>
</tr>
<tr>
<td> 密码:<input id="pwd" type="password" name="pwd"
class="inputs" /></td>
</tr>
<tr>
<td style="height: 35px; padding-left: 30px;"><input
id="btn" type="submit" value="登录" class="rb1" /></td>
</tr>
</form>
</table>
</td>
</tr>
<tr>
<td><img src="images/dl_l_b.gif" width="362" height="5" /></td>
</tr>
</table>
</div>
<div id="footer" class="main">
<a href="#">关于我们</a> | <a href="#">诚聘英才</a> |<a href="#"> 联系方式</a> | <a
href="#">帮助中心</a>
</div>

</body>




内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐