Hi,
There are many ways you could do this and it all depends on the situation.
Here is the most basic.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
.off {
display:none
}
.on {
display:inline
}
.address input {
display:block;
margin:3px 0 10px
}
br {
clear:both;
width:100%;
margin:0
}
.address span {
color:red;
font-weight:bold
}
</style>
</head>
<body>
<form id="form1" method="post" action="">
<fieldset class="address">
<legend>Address</legend>
<label for="Name">Enter Name | </label>
<span class="error off">You must enter your Name</span>
<input type="text" name="Name" id="Name" />
<br />
<label for="addr1">Enter Address Line1 | </label>
<span class="error on">Adress Line 1 required</span>
<input type="text" name="addr1" id="addr1" />
<br />
</fieldset>
</form>
</body>
</html>
Ideally the error messages should only be added to the mark up dynamically when necessary.
Bookmarks