How to do Encryption and Decryption using JQuery Plugin?



Introduction: 

Most of the times, we have give encrypt and decrypt our security in the browser operation.

Description: 

In the privous example, we have seen how to create anchor tag dynamically.  

In this JQuery example i am going to explain how to do encrypt and decrypt our security data and how to disable and enable button using JQuery.

Here we using third party plug-in for doing encryption and decryption operations.

Code: 

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/md5.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/aes.js"></script>

<script>
$(document).ready(function(){
 $('#btnDecryption').attr('disabled','disabled');
 
 $('#btnEncryption').click(function(){
  var encryptionText=$('#txtEncryption').val();
  $('#EncryptionText').text(CryptoJS.AES.encrypt(encryptionText, "/"));
  $('#btnDecryption').removeAttr('disabled');
 });
 
 $('#btnDecryption').click(function(){
  var decryptionText=$('span#EncryptionText').text();
  $('#DecryptionText').text((CryptoJS.AES.decrypt(decryptionText, "/")).toString(CryptoJS.enc.Utf8));
  
 });
});
</script>
</head>
<body>
<b>Welcome to JQueryExampleCode.blogspot.com</b>
<br /><br />
<input type="text" id="txtEncryption" />
<br />
<input type="button" id="btnEncryption" value="Encrypt" />
<br />
<b>Encryption Text:</b> <span id="EncryptionText"> </span> <br />
<input type="button" id="btnDecryption" value="Decrypt" />
<br />
<b>Decryption Text:</b><span id="DecryptionText" style="background-color:yellow"> </span> <br>
</body>
</html>

Video Tutorial: 

Output: 


Check box checked and unchecked using JQuery

By using below code, if we check on one check box, all other check boxes will checked, if we un check all other check boxes will unchecked.


<!DOCTYPE html>

<html>

<head>

    <title></title>

<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>

    <script language="javascript">

        $('document').ready(function() {

            $('#requestAccommodication').bind("click", doOperations);



        });

        var doOperations = (function () {

            debugger;

            if ($('#hai #requestAccommodication').is(':checked')) {

                $("#hai input[type=checkbox]").each(function () {

                    $(this).prop("checked", true);

                });

            } else {

                $("#hai input[type=checkbox]").each(function () {

                    $(this).prop("checked", false);

                });

            }

        });

    </script>

</head>

    <body>

        <div id="hai">

        <input type="checkbox" id="requestAccommodication" /><br />

        <input type='checkbox' name="1" id='isAccommadation_1' />JQuery

        <input type='checkbox' name="2" id='isAccommadation_2' />Example

        <input  type='checkbox' name="3" id='isAccommadation_3' />Code

            </div>

    </body>

</html>

Difference between window.onload and ready event in the JQuery

Introduction: 

Using this JQuery tutorial, we will learn what is the difference between window.load and document.ready event in the JQuery.

Description: 

JQuery code fires DOM is ready to be traversed and manipulated. But for some of the situations, we need to wait for complete window and resources must be load. In that situations we have to use the load() event with JQuery.

Please go through below JQuery Example. If you run below code u will get homepage as silver code after clicking on alert you will get background color as green.

Main code:



                  $(document).ready(function () {
                      $(document.body).css('background-color', 'silver');
                  });

                  $(window).load(function () {
                      alert('this will alert after all the window resources completly loaded');
                      $(document.body).css("background-color", "green");
                  });
              


Complete Code:


<html>
<head>
    <title></title>
              <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
              <script type="text/javascript">
                  $(document).ready(function () {
                      $(document.body).css('background-color', 'silver');
                  });

                  $(window).load(function () {
                      alert('this will alert after all the window resources completly loaded');
                      $(document.body).css("background-color", "green");
                  });
              
              </script>
</head>
<body>

</body>
</html>




Output: 

Before window load:

Before window load JQuery
Before window load:



After window load:
After window load in JQuery
After window load in JQuery


jQuery Basic Tutorial or concepts


jQuery Basic Tutorial

  1. Lesson Introduction
  2. Introducing jQuery
  3. Using $(document).ready()
  4. Including and Using jQuery
  5. Selecting Elements
  6. Selecting
  7. Selecting Elements Reviewed
  8. Working with Selections
  9. CSS, Styling, and Dimensions
  10. Traversing
  11. Traversing Reviewed
  12. Traversing
  13. Manipulating the DOM
  14. Manipulating
  15. Manipulating the DOM Reviewed

JQuery Ready() function syntax and usage


JQuery fires the custom event called ready(), whenever DOM is loaded and ready for manipulation.

If you want to execute any kind of events, what should work from this ready() handler only.

There are different ways are there for using ready function in the JQuery. Here i am discussing three ways.

Way 1

        // Standard.
        jQuery(document).ready(function () { alert('DOM Ready!'); });


Way 2

        jQuery(function () { alert('Using this syntax also DOM is ready'); });


Way 3

        jQuery(function ($) {
            alert('Here also DOM is loaded');
        });



Output:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
      <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script type="text/javascript">
        // Standard.
        jQuery(document).ready(function () { alert('jqueryexamplecode.blogspot.com'); });

        jQuery(function () { alert('Using this syntax also DOM is ready'); });

        jQuery(function ($) {
            alert('Here also DOM is loaded');
        });
    </script>
</head>
<body>
</body>
</html>


Output:
JQuery Ready() function syntax and usage
JQuery Ready() function syntax and usage
If you know any other ways, you can write in the comments section. 

jQuery Core Tutorial


jQuery Core

  1. Lesson Introduction
  2. $ vs jQuery
  3. $ vs $()
  4. $ vs $()
  5. Utility Methods
  6. Utility Methods Reviewed

How to use $ or jQuery keyword differently in JQuery coding


After some days with jquery, i got a doubt like "can we customize $ or jQuery keyword in jquery coding". We can do that using JQuery.

It is very simple to do conversion of $ with your custom name.

Main Code:

              var JQueryExampleCode = $; //(or) jQuery

              JQueryExampleCode(function () {
                  JQueryExampleCode('body').css("background-color", "Silver}");
                  alert('JQueryExampleCode.blogspot.com'); 
              });


Complete Code:


<html>
<head>
    <title></title>
          <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
          <script type="text/javascript">
              var JQueryExampleCode = $; //(or) jQuery

              JQueryExampleCode(function () {
                  JQueryExampleCode('body').css("background-color", "Silver}");
                  alert('JQueryExampleCode.blogspot.com'); 
              });
          </script>
</head>
<body>
This is body content. 
</body>
</html>
 

Output:

How to use $ or jQuery keyword differently in JQuery coding
How to use $ or jQuery keyword differently in JQuery coding

JQuery Tutorial or Lessons

JQuery Tutorial or Lessons


I am offering JQuery training with low cost in the Bangalore. I will training in the Weekends only. Training cost will be 2, 000 rupees. 

Interested people can send mail to me : dotnetrangarajesh@gmail.com


1.  JAVASCRIPT Basics

  1. Lesson Introduction
  2. Syntax Basics
  3. Reserved Words
  4. JS Basics Quiz 1
  5. Operators
  6. Operations on Numbers and Strings
  7. Operations on Numbers and Strings Reviewed
  8. Logical Operators
  9. Comparison Operators
  10. JS Basics Quiz 2
  11. Conditional Codes
  12. Conditional Variable Assignments with the Ternary Operator
  13. Switch Statements
  14. Loops
  15. Arrays
  16. Objects
  17. Objects Reviewed
  18. Functions
  19. JS Basics Quiz 3
  20. Testing Type
  21. Scope
  22. Scope Reviewed
  23. Closures
2.  jQuery Basic Concepts

  1. Lesson Introduction
  2. Including jQuery
  3. Using $(document).ready()
  4. Including and Using jQuery
  5. Selecting Elements
  6. Selecting
  7. Selecting Elements Reviewed
  8. Working with Selections
  9. CSS, Styling, and Dimensions
  10. Traversing
  11. Traversing Reviewed
  12. Traversing
  13. Manipulating the DOM
  14. Manipulating
  15. Manipulating the DOM Reviewed



 3.      jQuery Core

  1. Lesson Introduction
  2. $ vs jQuery
  3. $ vs $()
  4. $ vs $()
  5. Utility Methods
  6. Utility Methods Reviewed 


 4.     Events and Event Handlers
  1. Lesson Introduction
  2. Connecting Events to Elements
  3. Connecting Events to Elements Reviewed
  4. Inside the Event Handling Function
  5. Triggering Event Handlers
  6. Triggering Event Handlers Reviewed
  7. Increasing Performance with Event Delegation
  8. Event Helpers
  9. Create an Input Hint
  10. Create an Input Hint Reviewed
  11. Add Tabbed Navigation


 5.   EFFECTS
  1. Lesson Introduction
  2. Built-in Effects
  3. Built-in Effects Reviewed
  4. Limitations on Effects
  5. Queuing of Effects with Other Operations
  6. Queuing of Effects with Other Operations Reviewed
  7. Callbacks - Doing Something When an Effect is Done
  8. Custom Effects with $.fn.animate
  9. Custom Effects with $.fn.animate Reviewed
  10. Managing Effects
  11. Reveal Hidden Text
  12. Create Dropdown Menus
  13. Effects Exercises 6 & 7 Reviewed
  14. Create a Slideshow

  
6.     Ajax

  1. Lesson Introduction
  2. Key Concepts
  3. jQuery Ajax-Related Methods
  4. jQuery  Ajax-Related Methods Reviewed
  5. Ajax and Forms
  6. Working with JSON
  7. Working with JSON Reviewed
  8. Ajax Events
  9. Load External Content
  10. Load Content Using JSON
  11. Load Exercises Reviewed


 7.      Plug ins
  1. Lesson Introduction
  2. How to Create a Basic Plugin
  3. How to Create a Basic Plugin Reviewed
  4. Finding and Evaluating Plugins
  5. Creating a Plugin Using the Alsup Pattern
  6. Creating a Plugin Using the Alsup Pattern Exercise Reviewed
  7. Writing Stateful Plugins with the jQuery UI Widget Factory
  8. Make a Table Sortable (Optional)
  9. Make a Table Sortable Exercise Reviewed


 8.     Custom Events
  1. Lesson Introduction
  2. About Custom Events
  3. About Custom Events Reviewed
  4. Custom Events
  5. Review of Custom Events Exercise
  6. Conclusion



 9.     Best Practices

  1. Lesson Introduction
  2. JavaScript Best Practices
  3. JavaScript Best Practices Reviewed
  4. jQuery Best Practices
  5. jQuery Best Practices Reviewed
  6. Code Organization
  7. Code Organization Reviewed
  8. Do Not Treat jQuery as a Black Box