Friday, May 18, 2012

VALIDATIONS in JAVASCRIPT


<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<%@ page import="java.lang.*"%>
<%! static int temp=0;%>
<%
try
{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection cn=DriverManager.getConnection("jdbc:odbc:database");
Statement stat = cn.createStatement();
ResultSet rs  = stat.executeQuery("select max(form_no) from hostel");


   while(rs.next())
  {
 
  temp=rs.getInt(1);
  temp=temp+1;
     
  }
       stat.close();
      rs.close();
      cn.close();

}
catch(Exception e)
{
}
%>

<%%>


<html>
<!-- CSS -->


<style type="text/css">
a{text-decoration:none}
a:hover{background-color:#cfd2d7;}
a:link{color:purple}
a:visited{color:purple;}
a:active{color:orange;}




p.serif{font-family:"Times New Roman",Times,serif;}
p.sansserif{font-family:Arial,Helvetica,sans-serif;}
</style>

<body>
<!-- Page starts -->


<!--Main table -->

<table border=1 bgcolor=skyblue height=730 width="750">

<tr>
<td>

<table BORDER=1  bgcolor=white background=  height=130 width=750>

<tr>
<td>
<!--sub Main table --><table  height=100 width=750>
<tr>

<td align="left">
<img src="images\fule.jpg" height="100" width="100">
</td>
<td width="550" align="center" >  <font face="Verdana" color=teal size="8"><b> Pune University</b></font><br><br> <font face="papyrus" color="brown" size=4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b>Oxford of the East..  </td>



<td align="right"> </font>
<img src="images\sav.jpg" height="100" width="100">
</td>


</tr>
<!--Main table --></table>
</td>
</tr>

<tr>
<td>
<table border=1 background="images\bckg1.png" align="center"height="30" width="750">
<tr>
<td  align=center> <a href="index.html">  <font face="calibri" size="5">Home </font> </td>
<td  align=center> <a href="aboutuni.html">  <font face="calibri" size="5">              About university</td>
<td  align=center> <a href="academic.html">  <font face="calibri" size="5">   Academic </td>
<td  align=center> <a href="administration.html">  <font face="calibri" size="5">   Administration </td>
<td  align=center> <a href="feedback.jsp">  <font face="calibri" size="5">   Feedback </td>
<td  align=center> <a href="contact.html">  <font face="calibri" size="5">   Contact</td>
<td  align=center> <a href="admin.html">  <font face="calibri" size="5">   Admin </td>


</tr>

</table>


</td>
</tr>
</table>

</td>
</tr>



<tr>
<td>
<table border=1  bgcolor=skyblue height=150 width=750>
<tr>
<td  width=200>

<table border=1 background="images\bckg1.png" height=150 width=200>
<tr>
<td   align=center> <a href="distancelearning.html"> <font face="calibri" size="5"> Distance learning</font>     </td> </tr>
<tr><td  align=center> <a href="career.html">   <font face="calibri" size="5">    Career </td></tr>
<tr><td  align=center> <a href="studentCorner.html">   <font face="calibri" size="5">     Student Corner </td></tr>
<tr><td  align=center> <a href="hostel.jsp">   <font face="calibri" size="5">     Hostel </td>
</tr>
</table>
</td>

<td align=center height=150 width=400 background=>
<img src="images\hb.jpg" height=150 width=400>
</td>

<td align="center" height=150 width="150" >

<img src="images\gy.jpg" height="150" width="140">

</td>

</tr>
</table>



</td>
</tr>


<tr>
<td align="center">

<li><font face="calibri" size="5"><b>  Hostel Information : - <a href ="images\pdf\hostelinfo.pdf">   CLICK HERE </a><br><br>
<li>Hostel Rules :- <a href="images\pdf\hostelr.pdf"> CLICK HERE </a><br><br>
<li>Hostel Fees :- <a href="images\pdf\hostelf.pdf">  CLICK HERE </a><br><br>
<font face="calibri" size="4">if you accept terms and conditions then only fill the form<br><br>
</td>
</tr>


<tr>
<td align=left bgcolor=skyblue>


<form action="http://localhost:8080/hostel1.jsp" method="post" name="hf" onsubmit="return validateForm()">



<table  align="left" width="100%" border=0 cellspacing="0" cellpadding="0">

<tr>
<td bgcolor="#EFFCFC" align="center"><font face="calibri" color="teal" size="6">
HOSTEL ADMISSION FORM</font></td></tr>


<tr><td align=center> <br><br><img src="images\man1.jpg" height=10 width=10><font face="calibri" color="brown" size="3"> &nbsp;&nbsp;<b>marked options are mandatory</b></td>
</tr>


<tr>
<td bgcolor=skyblue colspan=100%>

<br><br><table align="left" border=0 cellspacing="0" cellpadding="0" width="600" >

<tr>

<td align="right"> <font face="calibri" color=gray><b> Form No. :
 <b></td>
<td> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="fn" size=1 value=<%=temp%>> </td>

</tr>

<tr>
<td>&nbsp;<td>
</tr>


<tr>

<td align="right"> <font face="calibri"><b> First Name :
<img src="images\man1.jpg" height=10 width=10> <b></td>
<td> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="fname" size=20 title="Enter your First name"> </td>

</tr>

<tr>
<td>&nbsp;<td>
</tr>



<tr>
<td align="right"> <font face="calibri"><b> Last Name :<img src="images\man1.jpg" height=10 width=10> </b></td>
<td> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="lname" size=20 title="Enter your Last name"> </td>

</tr>

<tr>
<td >&nbsp;<td>
</tr>

<tr>
<td align="right"><font face="calibri"> <b>Gender :<img src="images\man1.jpg" height=10 width=10> </b></td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="radio" name="gender" value="Male" /> Male
<input type="radio" name="gender" value="Female" /> Female
</td>
</tr>

<tr>
<td>&nbsp;<td>
</tr>




<tr>
<td align="right"> <font face="calibri"> <b>D.O.B :<img src="images\man1.jpg" height=10 width=10> </b></td>
<td> &nbsp;&nbsp;
<select name="d"> <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><option>11</option><option>12</option><option>13</option><option>14</option><option>15</option><option>16</option><option>17</option><option>18</option><option>19</option><option>20</option><option>21</option><option>22</option><option>23</option><option>24</option><option>25</option><option>26</option><option>27</option><option>28</option><option>29</option><option>30</option><option>31</option> </select> &nbsp;
<select name="m"> <option>jan</option><option>feb</option><option>mar</option><option>apr</option><option>may</option><option>jun</option><option>july</option><option>aug</option><option>sep</option></option><option>oct</option></option><option>nov</option></option><option>dec</option> </select>&nbsp;
<select name="y"> <option>1992</option><option>1991</option><option>1990</option><option>1989</option><option>1988</option><option>1987</option><option>1986</option><option>1985</option><option>1984</option></option><option>1983</option></option><option>1982</option></option><option>1981</option> </select>
</tr>

<tr>
<td >&nbsp;<td>
</tr>








<tr>
<td align="right"> <font face="calibri"> <b>Contact Number :<img src="images\man1.jpg" height=10 width=10> </b></td>
<td> &nbsp;&nbsp;+91-
<input type="text" name="cnum" size=20 maxlength="10" title="Enter your Contact Number">     &nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;(only 10 Digit) </td>
</tr>

<tr>
<td >&nbsp;<td>
</tr>

<tr>
<td align="right"> <font face="calibri"> <b>Landline Number : </b></td>
<td> &nbsp;&nbsp;+91-<input type="text" name="lnum" size=20 title="Enter your Landline Number"><br> </td>
</tr>


<tr>
<td >&nbsp;<td>
</tr>


<tr>
<td align="right"> <font face="calibri"> <b>Permanent Address :<img src="images\man1.jpg" height=10 width=10> </b></td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<textarea name="padd" value="padd" style="scrollbar-arrow-color:yellow;
                 scrollbar-base-color:skyblue;
                 scrollbar-darkshadow-color:blue;
                 scrollbar-highlightcolor:yellow;
                 scrollbar-shadow-color:blue" rows="3" cols="20" title="Enter your Permanent Address">
 </textarea></td>
</tr>

<tr>
<td>&nbsp;<td>
</tr>


<tr>
<td align="right"> <font face="calibri"><b> City :<img src="images\man1.jpg" height=10 width=10> </b></td>
<td> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="city" size=20 title="Enter your City"> </td>

</tr>

<tr>
<td>&nbsp;<td>
</tr>

<tr>
<td align="right"> <font face="calibri"><b> State :<img src="images\man1.jpg" height=10 width=10> </b></td>
<td> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="state"  size=20 title="Enter your state"> </td>

</tr>



<tr>
<td >&nbsp;<td>
</tr>

<tr>
<td align="right"> <font face="calibri"> <b>why do u need hostel? :<img src="images\man1.jpg" height=10 width=10> </b></td>
<td> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<textarea name="terms" style="scrollbar-arrow-color:yellow;
                 scrollbar-base-color:skyblue;
                 scrollbar-darkshadow-color:blue;
                 scrollbar-highlightcolor:yellow;
                 scrollbar-shadow-color:blue" rows="3" cols="20" title="Enter the details why do you need hostel">


</textarea></td>
</tr>

<tr>
<td>&nbsp;<td>
</tr>

<tr>

<td align=right colspan=100%><input type="checkbox" name="chkbox">I accept the terms and conditions.</td>

</tr>

<tr>
<td>&nbsp;<td>
</tr>

<tr>
<td align="right"> <input type="submit" value="submit" title="Click here to submit the form"></td>
<td align="center"> <input type="reset" name="reset" title="Click here to Clear the form"> </font>
</td>
</tr>
</table>
</td>
</tr>



</table>

</form>




</td>

</tr>



<!-- Footer -->


<tr>
<td>



<table  border=0 background="images\c.jpg" height=50 width=760>

<tr>
<td align=center colspan=95%>

<table border=0   align="center"height="30" width="300">
<tr>
<td  align=center> <a href="index.html">  <font face="calibri"  size="2"> Home|</font></td>
<td  align=center> <a href="aboutuni.html">  <font face="calibri" size="2">                   About Us|</td>
<td  align=center> <a href="feedback.jsp">  <font face="calibri" size="2">                   Feedback| </td>
<td  align=center> <a href="contact.html">  <font face="calibri" size="2">                   Contac Us| </td>
<td  align=center> <a href="admin.html">  <font face="calibri" size="2">                  Admin </td>
</tr>

</table>
<font face="papyrus" size="2" color="purple">All rights are reserved @ <a href="index.html"><font face="calibri" size="1" color=#EFFCFC>&nbsp; WWW.UNIPUNE.COM</font></a>

</td>

<td align=right colspan=5%>
powered by <a href="powered.html"> <img src="images\log.jpg" height="30" width="30">
</td>
</tr>
</table>

</td>
</tr>

</table>
<!--Main table Closed -->
</body>

<!--VALIDATION PART-->

<script language="javascript">

function validateForm()
{
var x=document.forms["hf"]["fname"].value;
if (x==null || x=="")
  {
  alert("First name must be filled out");
document.forms["hf"]["fname"].focus();
  return false;
  }

var x=document.forms["hf"]["lname"].value;
if (x==null || x=="")
 {
  alert("Last name must be filled out");
document.forms["hf"]["lname"].focus();
  return false;
  }


  var x = document.forms["hf"]["cnum"].value;
        if(isNaN(x)|| x.indexOf(" ")!=-1)
{
              alert("Enter numeric value");
document.forms["hf"]["cnum"].focus();
return (false);

               }

       if (x.charAt(0)!="9")
{
                alert("Enter the number and it should start with 9");
       document.forms["hf"]["cnum"].focus();
                return (false);
                 }



  var x = document.forms["hf"]["lnum"].value;
        if(isNaN(x)|| x.indexOf(" ")!=-1)
{
              alert("Enter numeric value");
document.forms["hf"]["lnum"].focus();
return (false);

               }

       if (x.charAt(0)!="0")
{
                alert("code must be specified ");
document.forms["hf"]["lnum"].focus();
                return (false);
                 }




var x=document.forms["hf"]["padd"].value;
if (x==null || x=="")
  {
  alert("Address must be filled out");
document.forms["hf"]["padd"].focus();
  return false;
  }


var x=document.forms["hf"]["city"].value;
if (x==null || x=="")
  {
  alert(" name of the city must be filled out");
document.forms["hf"]["city"].focus();
  return false;
  }

var x=document.forms["hf"]["state"].value;
if (x==null || x=="")
  {
  alert(" name of the state must be filled out");
document.forms["hf"]["state"].focus();
  return false;
  }
var x=document.forms["hf"]["terms"].value;
if (x==null || x=="")
  {
  alert(" reason must be filled out");
document.forms["hf"]["terms"].focus();
  return false;
  }

if(document.hf.chkbox.checked==false)
{
 
  alert("you havn't accepted the terms and condition");
  return false;
  }

var qry= confirm ( "Are you sure you want to submit the form?");

if (!qry)
{
return false;

//document.write ("The form is submited sucessfully");
}


}

</script>
</html>








No comments:

Post a Comment