Forms In HTML5



HTML 5 has features in which used to be difficult in previous versions of Html, javascript and CSS combination.

In this example:

HTML5 : Input validation

CSS3 : - renders the angled words on the top left
- the rounded corners

signup.html

Code:

<!DOCTYPE html>
<html>
<head>
<title>Marakana Form Example</title>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<link rel="stylesheet" href = "myCSSfile.css">

<script type="text/javascript">
</script>

</head>

<body>
<div id="container">
<header>
<h1>Class Signup</h1>
<h3 align="center">Get your top rated Open Source technology Training</h3>
<h2>&nbsp;</h2>
<h4>Get Training Results Now!</h4>
</header>

<nav>
<h2>Classes</h2>
<a href="" title="Home">Home</a>
<a href="signup.html" title="Get Ready To Learn">Sign Up</a>
<a href="" title="More About Marakana.com">About Marakana.com</a>
</nav>

<section>
<article>
<h2>HTML5</h2>
<p id="leaderboardStatus">Marakana Training: Connecting...</p>
<div id="leaderboard"></div>
</article>

<article>
<h2>Class Sign Up</h2>
<p><strong>Free Open Source Class</strong>: $0 </p>
<p>Payment to Other Open Source Classes</p>
<p><strong>NOTE :</strong> All Participants for training need to have basic programming knowledge to success in open source. </p>
<form method="post"
enctype="application/x-www-form-urlencoded"
action="">
<p><label>Name: <input name="name" required></label></p>
<p><label>Tel: <input name="telnumber" type=tel></label></p>
<p><label>Email: <input name="emailaddress required" type=email></label></p>
<p><label>Employer(If Any): <input type="datetime"></label></p>
<fieldset>
<legend>Programming Experience: </legend>
<p><label> <input type=radio name=size name="programming" value="None">None </label></p>
<p><label> <input type=radio name=size name="programming" value="Basic">Basic </label></p>
<p><label> <input type=radio name=size name="programming" value="Expert">Expert </label></p>
</fieldset>

<fieldset>
<legend>Meals Offered During Training Classes: </legend>
<p><label> <input type=checkbox name="extra" value="pasta">Pasta meal</label></p>
<p><label> <input type=checkbox name="extra" value="sandwich">Sandwich</label></p>
<p><label> <input type=checkbox name="extra" value="pizza">Pizza</label></p>
</fieldset>

<fieldset>
<legend>Expectations: </legend>
<p>
<label for="confidence">Your Learning Confidence Level</label>
<input id="confidence" name="level" type="range" min="1" max="100" value="0">
<output name="result" onforminput="value=level.value" >0</output>
</P>
<p><label>Notes: <textarea name="comments" maxlength=140></textarea></label></p>
</fieldset>
<p><button>Submit</button><p>
</form>

</article>
</section>

<aside>
<h4>Sponsors</h4>
<h2><p align="center">Kaazing</p></h2>
<h2><p align="center">SFHTML5.org</p></h2>
<p align="center"><img src="html5.jpg" alt="OpenSource Training" width="149" height="207"></p>
</aside>

<footer>
<p>Simply Powered by HTML5</p>
</footer>

</div>

</html>

The HTML5 page cannot work without corresponding CSS file

myCSSfile.css

Code:

/*
/* myCSSfile.css: Published with permission from the
/* author: Peter Lubbers, Kaazing HTML5 Training
*/

body {
background-color:#CCCCCC;
font-family:Geneva,Arial,Helvetica,sans-serif;
margin: 0px auto;
max-width:1000px;
border:solid;
border-color:#FFFFFF;
}

header {
background-color: #F47D31;
display:block;
color:#FFFFFF;
text-align:center;
width:100%;
}

h1 {
font-size: 72px;
margin: 0px;
}

h2 {
font-size: 24px;
margin: 0px;
text-align:center;
color: #F47D31;
}

h3 {
font-size: 18px;
margin: 0px;
text-align:center;
color: #F47D31;
}

h4 {
color: #F47D31;
background-color: #fff;
-webkit-box-shadow: 2px 2px 20px #888;
-webkit-transform: rotate(-45deg);
position: absolute;
padding: 0px 150px;
top: 50px;
left: -120px;
text-align:center;

}

header h2 {
margin: 0px;
}

nav {
display:block;
width:25%;
float:left;
}

nav a:link, nav a:visited {
display: block;
border-bottom: 3px solid #fff;
padding: 10px;
text-decoration: none;
font-weight: bold;
margin: 5px;
}

nav a:hover {
color: white;
background-color: #F47D31;
}

nav h3 {
margin: 15px;
color: white;
}

#container {
background-color: #888;
}

section {

display:block;
width:50%;
float:left;
}

article {
background-color: #eee;
display:block;
margin: 10px;
padding: 10px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}

article h2 {
}

aside {
display:block;
width:25%;
float:left;
}

footer {
clear: both;
display: block;
background-color: #F47D31;
color:#FFFFFF;
text-align:center;
padding: 15px;
}


/* links */
a {
color: #F47D31;
}

a:hover {
text-decoration: underline;
}

Screenshot

Source Code

https://www.protechtraining.com/static/tutorials/html5/HTML5-Forms.zip

Published May 19, 2010