All jQuery Code Examples

jQuery: Restrict occurrence of specific word in textbox

Below jQuery code allows to restrict user to enter any specific word only once in textbox. For demo, I have used "article" word and it should occur only once in textbox. The code also makes case insensitive search. $(document).ready(function () { $('#txtDesc').bind('keyup', function () { var txtToMatch = /article/gi; var iLimit = 1; var sMatch […]
Read the rest of this entry »

Detect Scroll Position (Up/Down) using jQuery

Below jQuery code detects whether user is scrolling up or down in the webpage. var iScrollPos = 0; $(window).scroll(function () { var iCurScrollPos = $(this).scrollTop(); if (iCurScrollPos > iScrollPos) { //Scrolling Down } else { //Scrolling Up } iScrollPos = iCurScrollPos; }); Live Demo Feel free to contact me for any help related to jQuery, […]
Read the rest of this entry »

Remove Weekends From jQuery UI Datepicker

In this post, find jQuery code to remove weekends rather than disabling them from jQuery UI Datepicker. This is quite useful when you don't want to allow users to select weekends. To disable weekends, all you need to do is to override ".ui-datepicker-week-end" css class and set display to none. .ui-datepicker-week-end { display:none } Live […]
Read the rest of this entry »

Check for ‘#’ hash in URL using jQuery

In this short post, find jQuery code to check if URL contains "#" (hash) or not. This can be checked via location.hash property provided by JavaScript and same can be used in jQuery. $(document).ready(function(){ if(window.location.hash) { // # exists in URL } else { // No # in URL. } }); Feel free to contact […]
Read the rest of this entry »

Highlight first day of every month in jQuery UI Datepicker

With continuation of jQuery UI Datepicker series articles, here is another post which gives solution to highlight very first day of each month in jQuery UI Datepicker control. First, define a CSS class to show highlighted effect. .firstDay a{ background-color : #00FF00 !important; background-image :none !important; color: #000 !important; } And use "beforeShowDay" event provided […]
Read the rest of this entry »

Show only Month and Year in only one jQuery UI DatePicker in case of Multiple DatePicker

In one of my previous post, I had posted about Show only Month and Year in jQuery UI DatePicker, but there was an issue with the code explained in that particular post. The issue was that it was applicable for all the datepickers present on the page and it is quite possible to have such […]
Read the rest of this entry »