Login Page
by Taqi_Shah
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<form id="login" method="post" action="">
<h1>Log in to your <strong>website.com</strong> account!</h1>
<p class="register">Not a member? <a href="#">Register here!</a></p>
<div>
<label for="login_username">Username</label>
<input type="text" name="username" id="login_username" class="field required" title="Please provide your username" />
</div>
<div>
<label for="login_password">Password</label>
<input type="password" name="password" id="login_password" class="field required" title="Password is required" />
</div>
<p class="forgot"><a href="#">Forgot your password?</a></p>
<div class="submit">
<button type="submit">Log in</button>
<label>
<input type="checkbox" name="remember" id="login_remember" value="yes" />
Remember my login on this computer
</label>
</div>
<p class="back"><a href="http://cssglobe.com/post/9688/the-anatomy-of-a-perfect-login-page">Go back to the article</a></p>
</form>
CSS
/* HTML elements */
h1, h2, h3, h4, h5, h6{
font-weight:normal;
margin:0;
line-height:1.1em;
color:#000;
}
h1{font-size:2em;margin-bottom:.5em;}
h2{font-size:1.75em;margin-bottom:.5142em;padding-top:.2em;}
h3{font-size:1.5em;margin-bottom:.7em;padding-top:.3em;}
h4{font-size:1.25em;margin-bottom:.6em;}
h5,h6{font-size:1em;margin-bottom:.5em;font-weight:bold;}
p, blockquote, ul, ol, dl, form, table, pre{line-height:inherit;margin:0 0 1.5em 0;}
ul, ol, dl{padding:0;}
ul ul, ul ol, ol ol, ol ul, dd{margin:0;}
li{margin:0 0 0 2em;padding:0;display:list-item;list-style-position:outside;}
blockquote, dd{padding:0 0 0 2em;}
pre, code, samp, kbd, var{font:100% mono-space,monospace;}
pre{overflow:auto;}
abbr, acronym{
text-transform:uppercase;
border-bottom:1px dotted #000;
letter-spacing:1px;
}
abbr[title], acronym[title]{cursor:help;}
small{font-size:.9em;}
sup, sub{font-size:.8em;}
em, cite, q{font-style:italic;}
img{border:none;}
hr{display:none;}
table{width:100%;border-collapse:collapse;}
th,caption{text-align:left;}
form div{margin:.5em 0;clear:both;}
label{display:block;}
fieldset{margin:0;padding:0;border:none;}
legend{font-weight:bold;}
input[type="radio"],input[type="checkbox"], .radio, .checkbox{margin:0 .25em 0 0;}
/* // HTML elements */
/* base */
body, table, input, textarea, select, li, button{
font:1em "Lucida Sans Unicode", "Lucida Grande", sans-serif;
line-height:1.5em;
color:#444;
}
body{
font-size:12px;
background:#c4f0f1;
text-align:center;
}
/* // base */
/* login form */
#login{
margin:5em auto;
background:#fff;
border:8px solid #eee;
width:500px;
-moz-border-radius:5px;
-webkit-border-radius:5px;
border-radius:5px;
-moz-box-shadow:0 0 10px #4e707c;
-webkit-box-shadow:0 0 10px #4e707c;
box-shadow:0 0 10px #4e707c;
text-align:left;
position:relative;
}
#login a, #login a:visited{color:#0283b2;}
#login a:hover{color:#111;}
#login...
JavaScript
jQuery(function($){
// simple jQuery validation script
$('#login').submit(function(){
var valid = true;
var errormsg = 'This field is required!';
var errorcn = 'error';
$('.' + errorcn, this).remove();
$('.required', this).each(function(){
var parent = $(this).parent();
if( $(this).val() == '' ){
var msg = $(this).attr('title');
msg = (msg != '') ? msg : errormsg;
$('<span class="'+ errorcn +'">'+ msg +'</span>')
.appendTo(parent)
.fadeIn('fast')
.click(function(){ $(this).remove(); })
valid = false;
};
});
return valid;
});
})