0
1.8kviews
What is JQUERY? Illustrate the use of JQUERY with a program

Mumbai University > Information Technology > Sem 4 > Web Programming

Marks: 10M

Year: May 2014, May 2015

1 Answer
1
3views
  • JQuery library is created by John Rosig in 2006. It is a Javascript library.
  • The purpose of JQuery is to write less do more.
  • JQuery adds up many advanced, cross browser functions to standard language.
  • There are two ways to execute JQuery:
    • Downloading JQuery library from jquery.com
    • Mentioning the URL to download JQuery library in a script tag

Advantages:

  • It is cross platform compatibility. It works on all platforms.
  • It is lightweight about 19kb in size.
  • It support abandon animation effects to make web document attractive.
  • It supports AJAX technology.
  • It supports DOM manipulations. One can select DOM elements, traverse them and modify their contents using JQuery.

Disadvantages:

  • JQuery can be used from the Internet or from downloaded JQuery library file.
  • JQuery must be coded in support of Javascript, PHP, ASP and AJAX to get advantage of its library functions
  • One of the major uses of JQuery is form Validation. JQuery eliminates the lengthy and complicated code in Javascript for form validation.
  • This is done in JQuery easily with the help of built invalidation function.
  • To achieve this, jquery.validate plugin will be needed.

    <head>
    <script src=”https://ajax.googleapps.comajax/libs/jquery/1.10.2/jquery.min.js>       </script>
    <script src=”https://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js”></script>
    </head>
    
  • The validate() function will be part of ready function in the script tag. This function is used to define rules and messages

Validate function

{
rules:{
        rules for field 1
        {
            attribute: value;
            attribute: value;
        }
messages: {
            field name 1: { attribute : your definition };
            field name 2: { attribute : your definition };
}
}

HTMl File:

<html>
<head>
<script src=”https://ajax.googleapps.comajax/libs/jquery/1.10.2/jquery.min.js></script>
<script src=”https://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js”></script>
<script>
$(document).readyfunction(0{
    		$(‘#myform’).validate({//initialize the plugin
rules: {
name:{
    required:true
    },
email id:{
        required: true,
        emaild:true
},
phone:{
    required: true,
    minlength;10    
},
messages:{
    name: {required:“Please enter your name”},
    email id: {email:”Please enter a valid email id”},
    phone: {minlength: “Please enter 10 digit phone number”}
}
});
</script>
</head>
<body>
<form id=”myform” method=”post”>
<table>
<tr>
    <td>name</td>
    <td><input type=”text” name=”name”/></td>
</tr>
<tr>
    <td>Email id</td>
    <td><input type=”text” name=”emailid”/></td>
</tr>
<tr>
    <td>Phone number</td>
    <td><input type=”text” name=”phone”/></td>
</tr>
<tr>
<td><input type=”submit”/></td>
</tr>
</table>
</form>
</body>
</html>
Please log in to add an answer.