Category Archives: JavaScript

Overloading vs Overriding in JavaScript

JavaScript does not support overloading. JavaScript supports overriding, so if you define two functions with the same name, the last one defined will override the previously defined version and every time a call will be made to the function, the last defined one will get executed. Example: <script type=”text/javascript”> function sum(x, y, z) { return… Read More »

jsGrid in jQuery

jsGrid is a lightweight client-side data grid control based on jQuery. It supports basic grid operations like inserting, filtering, editing, deleting, paging, and sorting. jsGrid is flexible and allows to customize its appearance and components. jsGrid CDN:- jsGrid is available on cdnjs. Here is the CDN links available: <link type=”text/css” rel=”stylesheet” href=”” /> <link type=”text/css”… Read More »

Method Chaining in Javascript

Method chaining is a technique that can be used to simplify code in scenarios that involve calling multiple functions on the same object consecutively. This chain is just a single expression. It’s easy enough to break this chain down and make each of the calls into separate expressions, but then it would obviously not be… Read More »

How to get Value from usercontrol to aspx page in Javascript

In this post i will show how to get value of a textbox of user control in page where that user control is registered.This question is asked in my many interview so come to the example lets first create a user control with the name of Test.  <%@ Control Language=”C#” AutoEventWireup=”true” CodeFile=”Test.ascx.cs” Inherits=”Test” %>… Read More »

Clear JS and CSS cache in jQuery

You can’t clear client system browser cache using jQuery or javascript but you can clear your application cache pragmatically. $(‘.button’).click(function() { $.ajax({ url: “”, context: document.body, success: function(s,x){ $(‘html[manifest=saveappoffline.appcache]’).attr(‘content’, ”); $(this).html(s); } }); }); or you have to disable the cache control <meta http-equiv=’cache-control’ content=’no-cache’> <meta http-equiv=’expires’ content=’0′> <meta http-equiv=’pragma’ content=’no-cache’>

JavaScript closures

JavaScript variables can belong to the local or global scope where as Private variables can be made possible with closures. A closure is an inner function that has access to the outer (enclosing) function’s variables—scope chain. The closure has three scope chains: it has access to its own scope (variables defined between its curly brackets),… Read More »

Disable Cut Copy Paste operation using jQuery

Somtimes we need to disable Cut, Copy, Paste content from textbox in our site due to some reasons(like don’t allow to copy password from password TextBox to Confirm password TextBox). We can implement this functionality with the help of below example. First create two textboxes control  password and  confirm password. <table> <tr><td>Password: </td><td><asp:TextBox ID=”txtPassword” runat=”server”></asp:TextBox></td></tr>… Read More »

Check whether a CheckBox is checked or not

Here I will show how to Check whether a CheckBox is checked or not with example. Check whether a CheckBox is checked (selected) or not using jQuery <script type=”text/javascript”> $(function () { $(“#btnCheck”).click(function () { var isChecked = $(“#chkbox”).is(“:checked”); if (isChecked) { alert(“CheckBox checked.”); } else { alert(“CheckBox not checked.”); } }); }); </script>

Radio button is check or not

Here I will show how to Check whether radio button is check or not with example. Radio button is check or not    <script type=”text/javascript”> function call() { var jq = jQuery.noConflict(); var rd = jq(“#s1”).is(‘:checked’); //.val(); alert(rd); } </script>

Special characters in javascript

function chkSpecialChars_citynu(input) { var iChars = “!@$%^&*()+=[];{}|<>?”; for (var i = 0; i < input.length; i++) { if (iChars.indexOf(input.charAt(i)) != -1) { return false; } } return true; }