Monday 18 February 2013

Code 4 form validation ( Simple )

<html>
<head>
      <title>Login Form</title>
</head>

<body
<center>

<h1 style="background-color:white;">log in form </h1>

<hr style="color:white;">

<form method="post" action="abc.php">

First  Name : &nbsp    &nbsp    &nbsp  &nbsp   &nbsp  &nbsp<input type="text" name="text"/>
<br>
<br>

Last Name : &nbsp    &nbsp    &nbsp  &nbsp   &nbsp  &nbsp<input type="text" name="text"/>
<br>
<br>


    Password: &nbsp    &nbsp    &nbsp  &nbsp   &nbsp  &nbsp &nbsp<input type="password" name="pwd"/>
<br>
<br>

Retype-Password: &nbsp<input type="password" name="pwd"/>
<br>
<br>


Email : &nbsp    &nbsp    &nbsp  &nbsp   &nbsp  &nbsp &nbsp &nbsp &nbsp <input type="text" name="text"/>
<br>
<br>


Gender :  &nbsp    &nbsp    &nbsp  &nbsp   &nbsp  &nbsp &nbsp <input type ="radio" name="sex" value="male">Male
         <input type ="radio" name="sex" value="male">Female

<br>
<br>

Date oF Birth : &nbsp    

 <select>

<option selected="selected">-Select Month-</option>
<option>Jan</option>
<option>Feb</option
<option>Mar</option>
<option>Apr</option>
<option>May</option>
</select>


<select>
<option selected="selected">Day</option>
<option>1</option>
<option>2</option
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
</select>

<select>
<option selected="selected">Year</option>
<option>2012</option>
<option>2011</option
<option>2010</option>
<option>2009</option>
<option>2008</option>
<option>2007</option>
<option>2006</option>
</select>

<br>
<br>

<input type="button" value="clear"/>

<input type="submit" value="submit"/>
<br>
<br>





</form>

</center>

</body>
</html>

Code 4 form validation by Bilal

<html>
<head>
      <title>Registration Form</title>
</head>

<body style="background-color:     #5F9EA0;">
<center>

<h1 style="background-color:silver;"><blink>Registration Form</blink> </h1>

<hr style="color:green;">

<form method="post" action="abc.php">

First  Name : &nbsp    &nbsp    &nbsp  &nbsp   &nbsp  &nbsp<input type="text" name="text"/>
<br>
<br>

Last Name : &nbsp    &nbsp    &nbsp  &nbsp   &nbsp  &nbsp<input type="text" name="text"/>
<br>
<br>


    Password: &nbsp    &nbsp    &nbsp  &nbsp   &nbsp  &nbsp &nbsp<input type="password" name="pwd"/>
<br>
<br>

Retype-Password: &nbsp<input type="password" name="pwd"/>
<br>
<br>


Email : &nbsp    &nbsp    &nbsp  &nbsp   &nbsp  &nbsp &nbsp &nbsp &nbsp <input type="text" name="text"/>
<br>
<br>


Retype-Email:  &nbsp    &nbsp    &nbsp  <input type="text" name="text"/>
<br>
<br>

Gender :  &nbsp    &nbsp    &nbsp  &nbsp   &nbsp  &nbsp &nbsp <input type ="radio" name="sex" value="male">Male
         <input type ="radio" name="sex" value="male">Female

<br>
<br>

Date oF Birth : &nbsp    

 <select>

<option selected="selected">-Select Month-</option>
<option>Jan</option>
<option>Feb</option
<option>Mar</option>
<option>Apr</option>
<option>May</option>
</select>


<select>
<option selected="selected">Day</option>
<option>1</option>
<option>2</option
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
</select>

<select>
<option selected="selected">Year</option>
<option>2012</option>
<option>2011</option
<option>2010</option>
<option>2009</option>
<option>2008</option>
<option>2007</option>
<option>2006</option>
</select>

<br>
<br>

&nbsp    &nbsp    &nbsp &nbsp    &nbsp    &nbsp  &nbsp    &nbsp    &nbsp <textarea name="texrarea" >Comments</textarea>
<br>
<br>

<input type="button" value="clear"/>

<input type="submit" value="submit"/>
<br>
<br>





</form>

</center>

</body>
</html>

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>
//fb like box