I am giving you the code that can be used in HTML. The example that I have mentioned below is somewhat complicated to show you the power of form validation. Here is the coding for same :
HTML Code:
<form name="a">
<fieldset>
<legend><b>Fill in current address.</b></legend>
<dl>
<dt><label id="fname" for="n1">First name</label> and <label id="lname" for="n2">Last name</label></dt>
<dd><input type="text" name="name" id="n1">
<input type="text" name="lastname" id="n2"></dd>
<dt><label id="ladd" for="address">Address</label></dt>
<dd><input type="text" name="address" size="55"
onfocus="highLabel('a1', '#ccf')" onblur="highLabel('a1', '')"></dd>
<dt><label id="lcity">Place</label>, <label id="lstate">State (two-letter abbreviation)</label>, and <label id="lzip">Zip</label></dt>
<dd><input type="text" name="city">,
<input type="text" name="state" size="4" maxlength="2">
<input type="text" name="zip" size="12" maxlength="10"></dd>
<dt><label id="lphone">Phone (area code and number)</label> and <label id="lemail">Email</label></dt>
<dd><input type="text" name="phone" size="18">
<input type="text" name="email" size="35"></dd>
</dl>
<p><input type="button" onclick=" validate(this.form, billing_address_check)
&& alert('All required fields are OK!')" value="Validate the Billing Address"></p>
</fieldset>
</form>
Bookmarks