Create Signup page with Validation using JavaScript

Code:
<html>
<head>

<title>Signup || Nested-code team</title>
<style type="text/css">
<!--
body {
margin-left: 150px;
margin-top: 5px;
margin-right: 190px;
background-color: #966;
}
-->
</style>
<script language="javascript">
function check()
{

 if(document.form1.lid.value=="")
  {
    alert("Plese Enter Login Id");
    document.form1.lid.focus();
    return false;
  }

 if(document.form1.pass.value=="")
  {
    alert("Plese Enter Your Password");
    document.form1.pass.focus();
    return false;
  }
  if(document.form1.cpass.value=="")
  {
    alert("Plese Enter Confirm Password");
    document.form1.cpass.focus();
    return false;
  }
  if(document.form1.pass.value!=document.form1.cpass.value)
  {
    alert("Confirm Password does not matched");
    document.form1.cpass.focus();
    return false;
  }
  if(document.form1.name.value=="")
  {
    alert("Plese Enter Your Name");
    document.form1.name.focus();
    return false;
  }
  if(document.form1.address.value=="")
  {
    alert("Plese Enter Address");
    document.form1.address.focus();
    return false;
  }
  if(document.form1.city.value=="")
  {
    alert("Plese Enter City Name");
    document.form1.city.focus();
    return false;
  }
  if(document.form1.phone.value=="")
  {
    alert("Plese Enter Contact No");
    document.form1.phone.focus();
    return false;
  }
  if(document.form1.email.value=="")
  {
    alert("Plese Enter your Email Address");
    document.form1.email.focus();
    return false;
  }
  e=document.form1.email.value;
        f1=e.indexOf('@');
        f2=e.indexOf('@',f1+1);
        e1=e.indexOf('.');
        e2=e.indexOf('.',e1+1);
        n=e.length;

        if(!(f1>0 && f2==-1 && e1>0 && e2==-1 && f1!=e1+1 && e1!=f1+1 && f1!=n-1 && e1!=n-1))
        {
            alert("Please Enter valid Email");
            document.form1.email.focus();
            return false;
        }
  return true;
  }

</script>
<link href="quiz.css" rel="stylesheet" type="text/css">
<style type="text/css">
body,td,th {
color: #C30;
}
a:link {
color: #06F;
}
a:visited {
color: #06F;
}
.d {
color: #0F0;
}
.dff {
color: #00F;
}
.y {
color: #FF0;
}
.style7 {
color: #0F0;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body><center></center>
<br>
<table width="100%" height="534" border="0">
   <tr>
     <td width="206" rowspan="2" valign="top">&nbsp;</td>
     <td width="651" height="57"><h1 align="left"><span class="d">New</span> <span class="dff">User</span><span class="style8"> <span class="y">Signup</span></span></h1></td>
   </tr>
   <tr>
     <td><form name="form1" method="post" action=" " onSubmit="return check();">
       <table width="532" height="341" border="0" align="left" bordercolor="#CCFF99" bordercolordark="#00CCFF" cellpadding="2" cellspacing="3" >
         <tr>
           <td><div align="left" class="style7">Login Id </div></td>
           <td><input type="text" name="lid"></td>
         </tr>
         <tr>
           <td class="style7">Password</td>
           <td><input type="password" name="pass"></td>
         </tr>
         <tr>
           <td class="style7">Confirm Password </td>
           <td><input name="cpass" type="password" id="cpass"></td>
         </tr>
         <tr>
           <td class="style7">Name</td>
           <td><input name="name" type="text" id="name"></td>
         </tr>
         <tr>
           <td valign="top" class="style7">Address</td>
           <td><textarea name="address" id="address"></textarea></td>
         </tr>
         <tr>
           <td valign="top" class="style7">City</td>
           <td><input name="city" type="text" id="city"></td>
         </tr>
         <tr>
           <td valign="top" class="style7">Phone</td>
           <td><input name="phone" type="text" id="phone"></td>
         </tr>
         <tr>
           <td valign="top" class="style7">E-mail</td>
           <td><input name="email" type="text" id="email"></td>
         </tr>
         <tr>
           <td>&nbsp;</td>
           <td><input type="submit" name="Submit" value="Signup">
           </td>
         </tr>
       </table>
     </form></td>
   </tr>
 </table>

<br><br><br><br><br>
<center></center>
</body>
</html>

Screen Shot:

Signup page with Validation

Popular posts from this blog

Real marksheet using HTML

Salary Calculate Application in C#