jQuery : get keycode and ascii

October 17th, 2012 § 0 comments § permalink

Keycode

You can get the keycode only in keyup or keydown event. if you are using jQuery event.which will hold the keycode

Charcode / Ascii

Charcode/Ascii is available only in keypress event. If you are in keypress event jQuery event.which will hold the ascii value instead of keycode.

You can easily convert the ascii to character with String.fromCharCode method.

Here is the working jsFiddle

jQuery : Disable holidays in jQuery UI calendar

May 19th, 2012 § 0 comments § permalink

Here is the simple way to disable custom holidays in a JQuery UI calendar. Here for example I took may 1, 2, and 3 to disable.
The trick lies in the beforeShowDay event. This event will be triggered before showing each day on calendar. It returns an array of 3 elements.

  1. true or false : false to disabled date.
  2. CSS class : A css class to style a particular day
  3. Tooltip Text : To show the description for a day.

The defaultDate option which I used, just to make sure this code always shows the May, 2012, else the datepicker will show the current month.

Hope you find it helpful.
Thank you.