1. Our login_shake.html
<html>
<head>
<title>the title</title>
<link rel='stylesheet' type='text/css' href='css/style.css'>
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.7.2.custom.min.js"></script>
<script src='js/myjs.js'></script>
</head>
<body>
<center>
<!--<button id="button"> Shake </button>-->
<!--<div class="target">
</div>-->
<div class='errors1'></div>
<br/>
<div id="container">
<label for="username">Username:</label>
<input type="text" id="username" name="username">
<label for="password">Password:</label>
<input type="password" id="password" name="password">
<div id="lower">
<input type="submit" id='button' class='button' value="Login">
</div><!--/ lower-->
</div>
</center>
</body>
</html>
2. Our style.css
body {
font-family: 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 13px;
text-align: center;
background: #E3CAA1;
}
#container {
position: absolute;
width: 340px;
height: 280px;
top: 50%;
left: 50%;
margin-top: -100px;
margin-left: -170px;
background: #fff;
border-radius: 3px;
border: 1px solid #ccc;
box-shadow: 0 1px 2px rgba(0, 0, 0, .1);
}
form {
margin: 0 auto;
margin-top: 20px;
}
label {
color: #555;
display: inline-block;
margin-left: 18px;
padding-top: 10px;
font-size: 14px;
}
p a {
font-size: 11px;
color: #aaa;
float: right;
margin-top: -13px;
margin-right: 20px;
-webkit-transition: all .4s ease;
-moz-transition: all .4s ease;
transition: all .4s ease;
}
p a:hover {
color: #555;
}
input {
font-family: "Helvetica Neue", Helvetica, sans-serif;
font-size: 12px;
outline: none;
}
input[type=text],
input[type=password] {
color: #777;
padding-left: 10px;
margin: 10px;
margin-top: 12px;
margin-left: 18px;
width: 290px;
height: 35px;
border: 1px solid #c7d0d2;
border-radius: 2px;
box-shadow: inset 0 1.5px 3px rgba(190, 190, 190, .4), 0 0 0 5px #f5f7f8;
-webkit-transition: all .4s ease;
-moz-transition: all .4s ease;
transition: all .4s ease;
}
input[type=text]:hover,
input[type=password]:hover {
border: 1px solid #b6bfc0;
box-shadow: inset 0 1.5px 3px rgba(190, 190, 190, .7), 0 0 0 5px #f5f7f8;
}
input[type=text]:focus,
input[type=password]:focus {
border: 1px solid #a8c9e4;
box-shadow: inset 0 1.5px 3px rgba(190, 190, 190, .4), 0 0 0 5px #e6f2f9;
}
#lower {
background: #ecf2f5;
width: 100%;
height: 69px;
margin-top: 20px;
box-shadow: inset 0 1px 1px #fff;
border-top: 1px solid #ccc;
border-bottom-right-radius: 3px;
border-bottom-left-radius: 3px;
}
input[type=checkbox] {
margin-left: 20px;
margin-top: 30px;
}
.check {
margin-left: 3px;
font-size: 11px;
color: #444;
text-shadow: 0 1px 0 #fff;
}
input[type=submit] {
float: right;
margin-right: 20px;
margin-top: 20px;
width: 80px;
height: 30px;
font-size: 14px;
font-weight: bold;
color: #fff;
background-color: #acd6ef; /*IE fallback*/
background-image: -webkit-gradient(linear, left top, left bottom, from(#acd6ef), to(#6ec2e8));
background-image: -moz-linear-gradient(top left 90deg, #acd6ef 0%, #6ec2e8 100%);
background-image: linear-gradient(top left 90deg, #acd6ef 0%, #6ec2e8 100%);
border-radius: 30px;
border: 1px solid #66add6;
box-shadow: 0 1px 2px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .5);
cursor: pointer;
}
input[type=submit]:hover {
background-image: -webkit-gradient(linear, left top, left bottom, from(#b6e2ff), to(#6ec2e8));
background-image: -moz-linear-gradient(top left 90deg, #b6e2ff 0%, #6ec2e8 100%);
background-image: linear-gradient(top left 90deg, #b6e2ff 0%, #6ec2e8 100%);
}
input[type=submit]:active {
background-image: -webkit-gradient(linear, left top, left bottom, from(#6ec2e8), to(#b6e2ff));
background-image: -moz-linear-gradient(top left 90deg, #6ec2e8 0%, #b6e2ff 100%);
background-image: linear-gradient(top left 90deg, #6ec2e8 0%, #b6e2ff 100%);
}
.errors1{
border:2px solid #B22222;
float:left;
margin-top:150px;
margin-left:330px;
background-color:#FF3030;
font-family:Baskerville;
width:325px;
font-weight:normal;
display:none;
font-size:20px;
text-align:left;
padding:5px;
}
.red{
background-color:#FF3030;
}
.green{
border:2px solid #8FBC8F;
float:left;
margin-top:150px;
margin-left:330px;
background-color:#228B22;
font-family:Baskerville;
width:325px;
font-weight:normal;
display:none;
font-size:20px;
text-align:left;
padding:5px;
color:#fff;
}
3. myjs.js
$(document).ready(function() {
$(".button").click(function(){
var uname = $('#username').val();
var pass = $('#password').val();
if(uname == "" && pass == "")
{
$('.errors1').text('Both Fields Are Mandatory').fadeIn(1000);
/*$('.errors1').text('Both Fields Are Mandatory').fadeIn(1000).delay(5000).fadeOut(1000);*/
$("#container").effect( "shake",
{times:3}, 100 );
$('#username').addClass('red');
$('#password').addClass('red');
setTimeout(function(){$('.errors1').fadeOut(1000)}, 5000);
}
else if(uname == "")
{
$('.errors1').text('Enter username to login').fadeIn(1000);
$("#container").effect( "shake",
{times:3}, 100 );
$('#username').addClass('red');
$('#password').removeClass('red');
setTimeout(function(){$('.errors1').fadeOut(1000)}, 5000);
}
else if(pass == "")
{
$('.errors1').text('Enter password to login').fadeIn(1000);
$("#container").effect( "shake",
{times:3}, 100 );
$('#password').addClass('red');
$('#username').removeClass('red');
setTimeout(function(){$('.errors1').fadeOut(1000)}, 5000);
}
else{
$('.errors1').fadeOut(1000);
$('#username').removeClass('red');
$('#password').removeClass('red');
}
});
});
LIVE DEMO
No comments:
Post a Comment
Thank your for your comment..your submitted coment will be live after admin approval