 |
|
Code (PHP)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Sign-in Or Register: Form Design From Scratch</title>
<link rel='stylesheet' href='css/master.css'>
<style type="text/css">
body,td,th {
font-family: HelveticaNeue-Light, "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
}
body {
margin-top: 0px;
margin-bottom: 0px;
}
</style>
</head>
<body>
<div id="pageContainer">
<!-- Tabs -->
<ul id="tabs" class="clearfix">
<li class="activeTab" id="signInTab">
<div class="signInTabContent">
<span>Already a member?</span>
<h1>Sign in below</h1>
</div>
<span class="activeTabArrow"><!-- --></span>
</li>
<li class="inactiveTab" id="signUpTab">
<div class="signUpTabContent">
<span>Don't have an account?</span>
<h1>Create one now</h1>
</div>
<span class="activeTabArrow"><!-- --></span>
</li>
</ul>
<!-- Sign In Tab Content -->
<div id="signIn" class="toggleTab">
<form action="#" method="POST" class="cleanForm">
<fieldset>
<p>
<label for="login-username">Your Username:</label>
<input type="text" id="login-username" name="login-username" value="" autofocus required />
</p>
<p>
<label for="login-password">Your Password:</label>
<input type="password" id="login-password" name="login-password" value="" required />
</p>
<div class="distanceLeft">
<input type="checkbox" id="remember-me" name="remember-me" />
<label for="remember-me">Remember me on this computer</label>
</div>
<input type="submit" value="Sign In" />
<div class="formExtra">
<p><strong>Trouble signing in?</strong></p>
<p><a href="#">Recover your password</a> or <a href="#">Create an account</a></p>
</div>
</fieldset>
</form>
</div> <!-- end signIn -->
<!-- Sign Up Tab Content -->
<div id="signUp" class="clearfix toggleTab">
<form action="#" method="POST" class="cleanForm" id="signUpForm">
<fieldset>
<p>
<label for="full-name">Full Name: <span class="requiredField">*</span></label>
<input type="text" id="full-name" name="full-name" value="" autofocus required />
<em>Enter your full name.</em>
</p>
<p>
<label for="username">Username: <span class="requiredField">*</span></label>
<input type="text" id="username" name="username" pattern="^[a-z0-9_-]{3,20}$" value="" required />
<em>Between 3 and 20 characters, letters or numbers.</em>
</p>
<p>
<label for="password">Password: <span class="requiredField">*</span></label>
<input type="password" id="password" name="password" value="" pattern="^[a-zA-Z0-9]{6,12}$" required />
<em>Between 6 and 12 characters, alphanumeric only.</em>
</p>
<p>
<label for="email">Email Address: <span class="requiredField">*</span></label>
<input type="email" id="email" name="email" value="" required />
<em>Must be a valid email address. E.g. [email protected]</em>
</p>
<p>
<label for="phone">Phone Number:</label>
<input type="tel" id="phone" name="phone" value="" pattern="^[0-9-]{10,}$" />
<em>10 or more characters, numbers and dashes only. E.g. 1-800-1111</em>
</p>
<div class="distanceLeft">
<input type="checkbox" id="terms" name="terms" />
<label for="terms">I have read and agree to the <a href="#">Terms of Service</a>.</label>
</div>
<input type="submit" value="Register" />
<div class="formExtra">
<p><strong>Note: </strong> Fields marked with <span class="requiredField">*</span> are required.</p>
</div>
</fieldset>
</form>
<!-- Sidebar -->
<div id="sidebar">
<h3>Benefits for signing up</h3>
<ul>
<li>24/7 support from our team</li>
<li>Another great benefit</li>
<li>We're in the cloud, so accessing your data will be 10x faster</li>
<li>We use the latest technology on the market today</li>
</ul>
</div> <!-- end sidebar -->
</div> <!-- end signUp -->
</div> <!-- end pageContainer -->
<!-- Include the JS files -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"></script>
<script src="js/h5f.js"></script>
<script src="js/functions.js"></script>
</body>
</html>
โค๊ดนี้อ่ะครับ
อันนี้เป็นไฟลืเสริมนะครับ
Code (PHP)
/**********************************************************************************
Project Name: Sign-in Or Register: Form Design From Scratch
Project Description: Video tutorial for Webdesign Tuts+
File Name: master.css
Author: Adi Purdila
Author URI: http://www.adipurdila.com
Version: 1.0.0
**********************************************************************************/
/* ---------- Based upon 'reset.css' in the Yahoo! User Interface Library: http://developer.yahoo.com/yui ---------- */
*, html, body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, label, fieldset, input, p, blockquote, th, td { margin:0; padding:0 }
table { border-collapse:collapse; border-spacing:0 }
fieldset, img { border:0 }
address, caption, cite, code, dfn, em, strong, th, var { font-style:normal; font-weight:normal }
ol, ul, li { list-style:none }
caption, th { text-align:left }
h1, h2, h3, h4, h5, h6 { font-size:100%; font-weight:normal }
q:before, q:after { content:''}
strong { font-weight:bold }
em { font-style:italic }
a img { border:none } /* Gets rid of IE's blue borders */
sup { font-size: 50%; }
a, a:hover { text-decoration: none; }
/* ---------- General Styles ---------- */
body {
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 300;
font-size: 12px;
line-height: 1.4em;
color: #3d3e41;
margin: 50px 0; /* Temporary margin to push down the form */
}
.clearfix:after {
visibility: hidden;
display: block;
content: "";
clear: both;
height: 0;
}
* html .clearfix { zoom: 1; } /* IE6 */
*:first-child+html .clearfix { zoom: 1; } /* IE7 */
em {
color: #808286;
margin-bottom: 20px;
display: block;
width: 280px;
font-weight: 300;
}
/* ---------- Structural Styles ---------- */
div#pageContainer {
width: 850px;
margin: 0 auto;
padding: 1px;
border: 1px solid #d7dadf;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
/* ---------- Tabs Styles ---------- */
ul#tabs {
background-color: #3d3e41;
}
ul#tabs li {
padding: 25px;
float: left;
}
ul#tabs li h1, ul#tabs li span { margin-left: 50px; }
ul#tabs li h1 {
font-size: 16px;
color: white;
text-transform: uppercase;
}
ul#tabs li span {
font-size: 12px;
color: #8c8e95;
display: block;
margin-bottom: 3px;
}
div.signInTabContent { background: url("../img/signInIcon.png") left center no-repeat; height: 36px;}
div.signUpTabContent { background: url("../img/signUpIcon.png") left center no-repeat; height: 36px; }
ul#tabs li.activeTab {
position: relative;
float: left;
}
ul#tabs li.activeTab span.activeTabArrow {
position: absolute;
background: url("../img/activeTabArrow.png") center center no-repeat;
width: 16px;
height: 8px;
top: 86px;
left: 34px;
margin: 0;
}
ul#tabs li.inactiveTab {
cursor: pointer;
border-left: 1px solid #41b2f2;
float: right;
background: #67c5fb; /* Fallback */
background: -moz-linear-gradient(left, #349bd7, #67c5fb 15%);
background: -webkit-gradient(linear, 0 0, 100% 0, from(#349bd7), color-stop(15%, #67c5fb));
}
ul#tabs li.inactiveTab:hover {
background: #7fcdf9; /* Fallback */
background: -moz-linear-gradient(left, #3aaaea, #7fcdf9 15%);
background: -webkit-gradient(linear, 0 0, 100% 0, from(#3aaaea), color-stop(15%, #7fcdf9));
}
ul#tabs li.inactiveTab span { color: #14567d; }
ul#tabs li.inactiveTab span.activeTabArrow { display: none; }
/* ---------- Sign In ---------- */
div#signIn, div#signUp {
padding: 50px 25px 30px 25px;
background: white; /* Fallback */
background: -moz-linear-gradient(top, white, #f0f2f4 1px, white 50px);
background: -webkit-gradient(linear, 0 0, 0 50, from(white), color-stop(2%, #f0f2f4), to(white));
}
div#signIn form.cleanForm { width: 440px; margin: 0 auto; }
div#signUp form.cleanForm { width: 500px; float: left; }
div#sidebar {
float: right;
padding: 25px;
width: 240px;
border: 1px solid #eaedf1;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-moz-box-shadow: inset 0 0 35px 5px #fafbfd;
-webkit-box-shadow: inset 0 0 35px 5px #fafbfd;
box-shadow: inset 0 0 35px 5px #fafbfd;
}
div#sidebar h3 {
font-weight: bold;
font-size: 14px;
margin-bottom: 20px;
}
div#sidebar ul li {
color: #808286;
background: url("../img/bulletPoint.png") left 3px no-repeat;
margin: 0 0 10px 20px;
padding-left: 15px;
}
/* ---------- Form Style ---------- */
form.cleanForm p { margin-bottom: 15px; }
form.cleanForm div a {
color: #1271c1;
border-bottom: 1px dotted #1271c1;
}
form.cleanForm div a:hover {
color: #3d3e41;
border-bottom: 1px dotted #3d3e41;
}
input[type="text"], input[type="password"], input[type="email"], input[type="tel"] {
color: #787a7e;
font-size: 18px;
padding: 0 15px;
border: 1px solid #d5d9de;
outline: none;
height: 50px;
width: 250px;
-moz-box-shadow: 0 0 0 5px #faf9f9, inset 0 0 5px 5px #faf9f9;
-webkit-box-shadow: 0 0 0 5px #faf9f9, inset 0 0 5px 5px #faf9f9;
box-shadow: 0 0 0 5px #faf9f9, inset 0 0 5px 5px #faf9f9;
}
input[type="submit"] {
border: 1px solid #39adf0;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
background: #6ac7fc; /* Fallback */
background: url("../img/submitButtonArrow.png") 88% center no-repeat, -moz-linear-gradient(top, #6ac7fc, #39adf0);
background: url("../img/submitButtonArrow.png") 88% center no-repeat, -webkit-gradient(linear, 0 0, 0 100%, from(#6ac7fc), to(#39adf0));
color: white;
font-size: 14px;
text-transform: uppercase;
font-weight: bold;
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
text-shadow: 1px 1px 0 #7a7a7a;
padding: 12px 45px 12px 15px;
cursor: pointer;
}
input[type="submit"]:hover {
background: #70d2fd; /* Fallback */
background: url("../img/submitButtonArrow.png") 88% center no-repeat, -moz-linear-gradient(top, #70d2fd, #3cb9f5);
background: url("../img/submitButtonArrow.png") 88% center no-repeat, -webkit-gradient(linear, 0 0, 0 100%, from(#70d2fd), to(#3cb9f5));
}
input[type="text"]:hover, input[type="text"]:focus, input[type="password"]:hover, input[type="password"]:focus,
input[type="email"]:hover, input[type="email"]:focus, input[type="tel"]:hover, input[type="tel"]:focus {
border: 1px solid #c1c5ca;
}
form.cleanForm p label {
font-weight: bold;
font-size: 14px;
display: block;
float: left;
width: 130px;
height: 55px;
line-height: 55px;
margin-right: 20px;
text-align: right;
}
form.cleanForm p em { margin-top: 15px; }
form.cleanForm span.requiredField {
font-size: 14px;
color: #ff0000;
}
div.formExtra, div.distanceLeft input[type="checkbox"], input[type="submit"], em { margin-left: 145px; }
div.distanceLeft { margin: 25px 0 20px 0; }
div.distanceLeft label { padding-left: 5px; }
/* ---------- Sign Up ---------- */
div#signUp { display: none; }
div#signUp form.cleanForm p label { width: 150px; }
div#signUp div.distanceLeft input[type="checkbox"],
div#signUp input[type="submit"], div#signUp em, div#signUp div.formExtra { margin-left: 165px; }
div.formExtra {
border-top: 1px solid #eeeded;
margin-top: 20px;
padding-top: 20px;
}
/* ---------- Inline Form Validation Styles ---------- */
div#signUp form.cleanForm input.valid {
background: url("../img/validationOk.png") 245px center no-repeat;
}
div#signUp form.cleanForm input.error {
background: url("../img/validationError.png") 245px center no-repeat;
border: 1px solid #f37f69;
-moz-box-shadow: 0 0 0 5px #f6cec7, inset 0 0 5px 5px #faf9f9;
-webkit-box-shadow: 0 0 0 5px #f6cec7, inset 0 0 5px 5px #faf9f9;
box-shadow: 0 0 0 5px #f6cec7, inset 0 0 5px 5px #faf9f9;
}
div#signUp form.cleanForm input.error + em { color: red; }
Code (PHP)
/*
* HTML5 Forms Chapter JavaScript Library
* http://thecssninja.com/javascript/H5F
*
* Copyright (c) 2010 Ryan Seddon - http://thecssninja.com/
* Dual-licensed under the BSD and MIT licenses.
* http://thecssninja.com/H5F/license.txt
*/
var H5F = H5F || {};
(function(d){
var field = d.createElement("input"),
emailPatt = new RegExp("([a-z0-9_.-]+)@([0-9a-z.-]+).([a-z.]{2,6})","i"),
urlPatt = new RegExp("^http:\/\/","i"),
usrPatt, curEvt, args;
H5F.setup = function(form,settings) {
var isCollection = !form.nodeType || false;
var opts = {
validClass : "valid",
invalidClass : "error",
requiredClass : "required"
};
if(typeof settings === "object") {
for (var i in opts) {
if(typeof settings[i] === "undefined") { settings[i] = opts[i]; }
}
}
args = settings || opts;
if(isCollection) {
for(var k=0,len=form.length;k<len;k++) {
H5F.validation(form[k]);
}
} else {
H5F.validation(form);
}
};
H5F.validation = function(form) {
var f = form.elements,
flen = f.length,
isRequired;
H5F.listen(form,"invalid",H5F.checkField,true);
H5F.listen(form,"blur",H5F.checkField,true);
H5F.listen(form,"input",H5F.checkField,true);
H5F.listen(form,"focus",H5F.checkField,true);
if(!H5F.support()) {
form.checkValidity = function(e,f) { H5F.checkValidity("",form); };
while(flen--) {
isRequired = !!(f[flen].attributes["required"]);
// Firefox includes fieldsets inside elements nodelist so we filter it out.
if(f[flen].nodeName !== "FIELDSET" && isRequired) {
H5F.validity(f[flen]); // Add validity object to field
}
}
}
};
H5F.validity = function(el) {
var elem = el,
missing = H5F.valueMissing(elem),
type = elem.getAttribute("type"),
pattern = elem.getAttribute("pattern"),
placeholder = elem.getAttribute("placeholder"),
isType = /^(email|url|password)$/i,
fType = ((isType.test(type)) ? type : ((pattern) ? pattern : false)),
patt = H5F.pattern(elem,fType),
step = H5F.range(elem,"step"),
min = H5F.range(elem,"min"),
max = H5F.range(elem,"max");
elem.validity = {
patternMismatch: patt,
rangeOverflow: max,
rangeUnderflow: min,
stepMismatch: step,
valid: (!missing && !patt && !step && !min && !max),
valueMissing: missing
};
if(placeholder && curEvt !== "input") { H5F.placeholder(elem); }
elem.checkValidity = function(e,el) { H5F.checkValidity(e,elem); };
};
H5F.checkField = function (e) {
var el = H5F.getTarget(e) || e, // checkValidity method passes element not event
events = /^(input|focusin|focus)$/i;
curEvt = e.type;
if(!H5F.support()) { H5F.validity(el); }
if(el.validity.valid) {
H5F.removeClass(el,args.invalidClass);
H5F.removeClass(el,args.requiredClass);
H5F.addClass(el,args.validClass);
} else if(!events.test(curEvt)) {
if(el.validity.valueMissing) {
H5F.removeClass(el,args.invalidClass);
H5F.removeClass(el,args.validClass);
H5F.addClass(el,args.requiredClass);
} else {
H5F.removeClass(el,args.validClass);
H5F.removeClass(el,args.requiredClass);
H5F.addClass(el,args.invalidClass);
}
} else if(el.validity.valueMissing) {
H5F.removeClass(el,args.requiredClass);
H5F.removeClass(el,args.invalidClass);
H5F.removeClass(el,args.validClass);
}
};
H5F.checkValidity = function (e,el) {
var f, ff, isRequired, invalid = false;
if(el.nodeName === "FORM") {
f = el.elements;
for(var i = 0,len = f.length;i < len;i++) {
ff = f[i];
isRequired = !!(ff.attributes["required"]);
if(ff.nodeName !== "FIELDSET" && isRequired) {
H5F.checkField(ff);
if(!ff.validity.valid && !invalid) {
ff.focus();
invalid = true;
}
}
}
} else {
H5F.checkField(el);
return el.validity.valid;
}
};
H5F.support = function() {
return (H5F.isHostMethod(field,"validity") && H5F.isHostMethod(field,"checkValidity"));
};
// Create helper methods to emulate attributes in older browsers
H5F.pattern = function(el, type) {
if(type === "email") {
return !emailPatt.test(el.value);
} else if(type === "url") {
return !urlPatt.test(el.value);
} else if(!type || type === "password") { // Password can't be evalutated.
return false;
} else {
usrPatt = new RegExp(type);
return !usrPatt.test(el.value);
}
};
H5F.placeholder = function(el) {
var placeholder = el.getAttribute("placeholder"),
focus = /^(focus|focusin)$/i,
node = /^(input|textarea)$/i,
isNative = !!("placeholder" in field);
if(!isNative && node.test(el.nodeName)) {
if(el.value === "") {
el.value = placeholder;
} else if(el.value === placeholder && focus.test(curEvt)) {
el.value = "";
}
}
};
H5F.range = function(el,type) {
// Emulate min, max and step
var min = parseInt(el.getAttribute("min"),10) || 0,
max = parseInt(el.getAttribute("max"),10) || false,
step = parseInt(el.getAttribute("step"),10) || 1,
val = parseInt(el.value,10),
mismatch = (val-min)%step;
if(!H5F.valueMissing(el) && !isNaN(val)) {
if(type === "step") {
return (el.getAttribute("step")) ? (mismatch !== 0) : false;
} else if(type === "min") {
return (el.getAttribute("min")) ? (val < min) : false;
} else if(type === "max") {
return (el.getAttribute("max")) ? (val > max) : false;
}
} else if(el.getAttribute("type") === "number") {
return true;
} else {
return false;
}
};
H5F.required = function(el) {
var required = !!(el.attributes["required"]);
return (required) ? H5F.valueMissing(el) : false;
};
H5F.valueMissing = function(el) {
var placeholder = el.getAttribute("placeholder");
return !!(el.value === "" || el.value === placeholder);
};
/* Util methods */
H5F.listen = function (node,type,fn,capture) {
if(H5F.isHostMethod(window,"addEventListener")) {
/* FF & Other Browsers */
node.addEventListener( type, fn, capture );
} else if(H5F.isHostMethod(window,"attachEvent") && typeof window.event !== "undefined") {
/* Internet Explorer way */
if(type === "blur") {
type = "focusout";
} else if(type === "focus") {
type = "focusin";
}
node.attachEvent( "on" + type, fn );
}
};
H5F.preventActions = function (evt) {
evt = evt || window.event;
if(evt.stopPropagation && evt.preventDefault) {
evt.stopPropagation();
evt.preventDefault();
} else {
evt.cancelBubble = true;
evt.returnValue = false;
}
};
H5F.getTarget = function (evt) {
evt = evt || window.event;
return evt.target || evt.srcElement;
};
H5F.addClass = function (e,c) {
var re;
if (!e.className) {
e.className = c;
}
else {
re = new RegExp('(^|\\s)' + c + '(\\s|$)');
if (!re.test(e.className)) { e.className += ' ' + c; }
}
};
H5F.removeClass = function (e,c) {
var re, m;
if (e.className) {
if (e.className == c) {
e.className = '';
}
else {
re = new RegExp('(^|\\s)' + c + '(\\s|$)');
m = e.className.match(re);
if (m && m.length == 3) { e.className = e.className.replace(re, (m[1] && m[2])?' ':''); }
}
}
};
H5F.isHostMethod = function(o, m) {
var t = typeof o[m], reFeaturedMethod = new RegExp('^function|object$', 'i');
return !!((reFeaturedMethod.test(t) && o[m]) || t == 'unknown');
};
})(document);
Code (PHP)
/**********************************************************************************
Project Name: Sign-in Or Register: Form Design From Scratch
Project Description: Video tutorial for Webdesign Tuts+
File Name: functions.js
Author: Adi Purdila
Author URI: http://www.adipurdila.com
Version: 1.0.0
**********************************************************************************/
$(document).ready(function() {
/* Activate H5F */
H5F.setup($("div#signUp form"));
$('ul#tabs li').click(function() {
/* If what we clicked is the actual link, we move make the changes */
if($(this).attr("class") == "inactiveTab") {
/* Swap classes on the clicked item */
$(this).addClass('activeTab').removeClass('inactiveTab');
/* Swap classes on the other LI */
$(this).siblings('.activeTab').removeClass('activeTab').addClass('inactiveTab');
/* Change the float of the previous element */
$(this).prev().css("float", "left");
/* We toggle the tabs */
$("div.toggleTab").slideToggle("fast", function() {
/* Once the animation is complete, focus the first field of the visible form */
$("div.toggleTab input:visible").first().focus();
});
}
});
});
ขอความกรุณาด้วยนะครับ พอดีผมโลหดมา แล้ว พยายามศึกษา แต่ไม่รู้เรื่องเลยอ่ะครับ
Tag : PHP
|
|
 |
 |
 |
 |
Date :
2013-06-24 00:03:14 |
By :
lungzee |
View :
840 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |