Code 4 form validation by Atiq
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Msc I.T F11 A32</title>
<style type="text/css">
.font{
font-size:18px;
}
</style>
<script type="text/javascript">
function validate(){
var fname = document.getElementById("first").value;
var lname = document.getElementById("last").value;
var dob = document.getElementById("dob").value;
var address = document.getElementById("address").value;
var country = document.getElementById("country").value;
var city = document.getElementById("city").value;
var email = document.getElementById("email").value;
var pass = document.getElementById("password").value;
var cpass = document.getElementById("password2").value;
var father = document.getElementById("fname").value;
if(!(fname == "")){
if((fname.length <3)||(isNaN(fname) == false)){
alert("First Name is Not Valid !");
}
else
if(!(lname == "")){
if((lname.length <3)||(isNaN(lname) == false)){
alert("Last Name is Not Valid !");
}
else
if(!(father == "")){
if((father.length <3)||(isNaN(father) == false)){
alert("father Name is Not Valid !");
}
else
if(!(dob == "")){
if((dob.length <8)||(isNaN(dob) == false)){
alert("Date of Birth is Not Valid !");
}
else
if(!(address == "")){
if((address.length < 8)||(isNaN(address) == false)){
alert("Address is Not Valid !");
}
else
if(!(country == "")){
if((country.length <5)||(isNaN(country) == false)){
alert("country Name is Not Valid !");
}
else
if(!(city == "")){
if((city.length <5)||(isNaN(city) == false)){
alert("City Name is Not Valid !");
}
else
if(!(email == "")){
if((email.length <12)||(isNaN(email) == false)){
alert("Email Address is Not Valid !");
}
else
if(!(pass == "")){
if(!(cpass == "")){
if(pass.length < 5){
alert("Password length must Greater than 5 !");
}
if(!(pass == cpass)){
alert("Your Password's does not match !");
}
if(isNaN(pass) == false){
alert("Password Must Contain some Alphabets !");
}
}else{
alert("Please Enter Confirm Password !");
}
}else{
alert("Please Enter Password !");
}
}else{
alert("Please Enter Email Address!");
}
}else{
alert("Please Enter your City Name !");
}
}else{
alert("Please Enter Your Country Name !");
}
}else{
alert("Please Enter Your Address !");
}
}else{
alert("Please Enter Your Date of Birth!");
}
}else{
alert("Please Enter Your Father Name !");
}
}else{
alert("Please Enter Your Last Name!");
}
}else{
alert("Please Enter Your First Name!");
}
}
</script>
</head>
<body bgcolor="#999999">
<form action="" method="get">
<br />
<br />
<br />
<br />
<br />
<table align="center" >
<tr>
<td colspan="3">
<label style="font-family:'Courier New', Courier, monospace; font-size:46px; font-weight:bolder; text-align:center; margin-left:30px">
Registration Form
</label>
</td>
</tr>
<tr><td><br /><br /></td></tr>
<tr>
<td>
<label class="font">Name </label>
</td><td>
<input type="text" size="20" class="font"id="first" /></td><td>
<input type="text" size="23" id="last" class="font"/>
</td>
</tr>
<tr>
<td><label class="font">Father Name</label>
</td>
<td colspan="2">
<input class="font" type="text" size="50" id="fname" /></td></tr>
<tr><td >
<label class="font">Date of Birth</label></td>
<td colspan="2"><input class="font" type="text" size="50" id="dob"/></td>
</tr>
<tr>
<td><label class="font">Gender </label></td>
<td>
<input name="gender" type="radio" class="font" id="gender1" value="male" checked="checked" />
<label class="font" >Male</label></td>
<td>
<input name="gender" type="radio" class="font" id="gender2" value="female" />
<label class="font">Female</label>
</td>
</tr>
<tr>
<td >
<label class="font">Address </label>
</td><td colspan="2">
<input type="text" class="font" size="50" id="address" width="300px" /></td>
</tr>
<tr>
<td >
<label class="font">Language</label>
</td><td colspan="2"><select name="language" class="font" id="language" style="width: 425px">
<option>Arabic</option>
<option>English</option>
<option>Urdu</option>
<option>French</option>
<option>Spanish</option>
</select></td>
</tr>
<tr><td>
<label class="font" >Country</label>
</td><td colspan="2">
<input type="text" size="50"class="font" id="country" /></td></tr>
<tr><td>
<label class="font">City</label>
</td><td colspan="2">
<input type="text" size="50"class="font" id="city" /></td></tr>
<tr><td>
<label class="font" >Email Address</label>
</td><td colspan="2">
<input type="email" size="50" class="font" id="email" /></td></tr>
<tr><td>
<label class="font" >Password</label>
</td><td colspan="2">
<input type="password" size="50" class="font" id="password" /></td></tr>
<tr><td>
<label class="font"> Confirm Password</label>
</td><td colspan="2">
<input type="password" size="50" class="font" id="password2" /></td></tr>
<tr><td><br /></td><td></td></tr>
<tr><td></td><td colspan="2">
<input type="button" style="margin-left:130px; font-size:18px;" value="Validate Data" onclick="validate();" />
</td></tr>
</table>
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Msc I.T F11 A32</title>
<style type="text/css">
.font{
font-size:18px;
}
</style>
<script type="text/javascript">
function validate(){
var fname = document.getElementById("first").value;
var lname = document.getElementById("last").value;
var dob = document.getElementById("dob").value;
var address = document.getElementById("address").value;
var country = document.getElementById("country").value;
var city = document.getElementById("city").value;
var email = document.getElementById("email").value;
var pass = document.getElementById("password").value;
var cpass = document.getElementById("password2").value;
var father = document.getElementById("fname").value;
if(!(fname == "")){
if((fname.length <3)||(isNaN(fname) == false)){
alert("First Name is Not Valid !");
}
else
if(!(lname == "")){
if((lname.length <3)||(isNaN(lname) == false)){
alert("Last Name is Not Valid !");
}
else
if(!(father == "")){
if((father.length <3)||(isNaN(father) == false)){
alert("father Name is Not Valid !");
}
else
if(!(dob == "")){
if((dob.length <8)||(isNaN(dob) == false)){
alert("Date of Birth is Not Valid !");
}
else
if(!(address == "")){
if((address.length < 8)||(isNaN(address) == false)){
alert("Address is Not Valid !");
}
else
if(!(country == "")){
if((country.length <5)||(isNaN(country) == false)){
alert("country Name is Not Valid !");
}
else
if(!(city == "")){
if((city.length <5)||(isNaN(city) == false)){
alert("City Name is Not Valid !");
}
else
if(!(email == "")){
if((email.length <12)||(isNaN(email) == false)){
alert("Email Address is Not Valid !");
}
else
if(!(pass == "")){
if(!(cpass == "")){
if(pass.length < 5){
alert("Password length must Greater than 5 !");
}
if(!(pass == cpass)){
alert("Your Password's does not match !");
}
if(isNaN(pass) == false){
alert("Password Must Contain some Alphabets !");
}
}else{
alert("Please Enter Confirm Password !");
}
}else{
alert("Please Enter Password !");
}
}else{
alert("Please Enter Email Address!");
}
}else{
alert("Please Enter your City Name !");
}
}else{
alert("Please Enter Your Country Name !");
}
}else{
alert("Please Enter Your Address !");
}
}else{
alert("Please Enter Your Date of Birth!");
}
}else{
alert("Please Enter Your Father Name !");
}
}else{
alert("Please Enter Your Last Name!");
}
}else{
alert("Please Enter Your First Name!");
}
}
</script>
</head>
<body bgcolor="#999999">
<form action="" method="get">
<br />
<br />
<br />
<br />
<br />
<table align="center" >
<tr>
<td colspan="3">
<label style="font-family:'Courier New', Courier, monospace; font-size:46px; font-weight:bolder; text-align:center; margin-left:30px">
Registration Form
</label>
</td>
</tr>
<tr><td><br /><br /></td></tr>
<tr>
<td>
<label class="font">Name </label>
</td><td>
<input type="text" size="20" class="font"id="first" /></td><td>
<input type="text" size="23" id="last" class="font"/>
</td>
</tr>
<tr>
<td><label class="font">Father Name</label>
</td>
<td colspan="2">
<input class="font" type="text" size="50" id="fname" /></td></tr>
<tr><td >
<label class="font">Date of Birth</label></td>
<td colspan="2"><input class="font" type="text" size="50" id="dob"/></td>
</tr>
<tr>
<td><label class="font">Gender </label></td>
<td>
<input name="gender" type="radio" class="font" id="gender1" value="male" checked="checked" />
<label class="font" >Male</label></td>
<td>
<input name="gender" type="radio" class="font" id="gender2" value="female" />
<label class="font">Female</label>
</td>
</tr>
<tr>
<td >
<label class="font">Address </label>
</td><td colspan="2">
<input type="text" class="font" size="50" id="address" width="300px" /></td>
</tr>
<tr>
<td >
<label class="font">Language</label>
</td><td colspan="2"><select name="language" class="font" id="language" style="width: 425px">
<option>Arabic</option>
<option>English</option>
<option>Urdu</option>
<option>French</option>
<option>Spanish</option>
</select></td>
</tr>
<tr><td>
<label class="font" >Country</label>
</td><td colspan="2">
<input type="text" size="50"class="font" id="country" /></td></tr>
<tr><td>
<label class="font">City</label>
</td><td colspan="2">
<input type="text" size="50"class="font" id="city" /></td></tr>
<tr><td>
<label class="font" >Email Address</label>
</td><td colspan="2">
<input type="email" size="50" class="font" id="email" /></td></tr>
<tr><td>
<label class="font" >Password</label>
</td><td colspan="2">
<input type="password" size="50" class="font" id="password" /></td></tr>
<tr><td>
<label class="font"> Confirm Password</label>
</td><td colspan="2">
<input type="password" size="50" class="font" id="password2" /></td></tr>
<tr><td><br /></td><td></td></tr>
<tr><td></td><td colspan="2">
<input type="button" style="margin-left:130px; font-size:18px;" value="Validate Data" onclick="validate();" />
</td></tr>
</table>
</form>
</body>
</html>
Comments
Post a Comment