Wednesday, 7 November 2012

Jquery Tutorial 1 with J2ee

//Jquery tutorial 1


Step 1 ) Download jquery-1.5.1.min.js this js file which is the base for jquery
Step 2) Download jquery.validate.min.js this js file which is base for validation
Step 3)Make a dynamic web project in eclipse and include the js files in webcontent under the jquerry folder as given bellow







Step 4) Make a jsp file with name login and place it in jsps folder as given above and paste the bellow content in it

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><%@page
    language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>Jquery login</title>
<title>The jQuery Structure</title>
<script type="text/javascript" src="<%=request.getContextPath() %>/jquerry/jquery-1.5.1.min.js"> </script>// main jquery js
<script type="text/javascript" src="<%=request.getContextPath() %>/jquerry/jquery.validate.min.js"></script>//validation js
   <script type="text/javascript">
    $(document).ready(function() {
       $("form").validate();//this is responsilble for validation
     });
   
   </script>
  
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<form action="" method="post">
<table>
<tr>
<th>Username:-</th>
<td> <input type="text" name="userName" class="required"></td>//add class required were ever you want validation
</tr>
<tr>
<th>
Password:-</th>
<td> <input type="text" name="password" class="required"></td>
</tr>
<tr>
<td>
<input type="submit" value="Login"/>
</td>
</tr>
</table>
</form>
</body>
</html>

Step 5) Right click on project clean build it and run it

output:-
the bellow will be the output if user clicks on submit without entering the data


No comments:

Post a Comment

Custom single threaded java server

 package com.diffengine.csv; import java.io.*; import java.net.*; import java.util.Date; public class Server { public static void main(Str...