In this blog I am going to show you how to build a nice form using css and validate the same.
Using JavaScript
First you need to create an html page like below:
<html>
<head>
<title>Form By Honey Chawla. </title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script language="javascript" src="script/validate.js" />
</head>
<body>
<br />
<form id="form1">
<p>
FirstName</p>
<input id="f" type="text" value="firstname" onfocus="this.value=' '" /><br />
<br />
<p>
LastName</p>
<input id="l" type="text" value="lastname" onfocus="this.value=' '" /><br />
<br />
<p>
Password</p>
<input id="p" type="password" value="enter password" onfocus="this.value=' '" /><br />
<br />
<p>
Repeat Password</p>
<input id="rp" type="password" value="repeat password" onfocus="this.value=' '" /><br />
<br />
<input id="button1" class="btn" type="button" value="Click To Submit" onclick="checkinput()" />
</form>
</body>
</html>
Create the following javascript
function checkinput() {
first = document.getElementById("f").value;
last = document.getElementById("l").value;
pwd = document.getElementById("p").value;

Join the conversation! Your thoughts help the community grow.