How to prevent user to enter text in textarea after reaching max character limit

The keyup event fires after the default behaviour (populating text area) has occurred. It’s better to use the keypress event, and filter non-printable characters. Demo: http://jsfiddle.net/3uhNP/1/ (with max length 4) jQuery(document).ready(function($) { var max = 400; $(‘textarea.max’).keypress(function(e) { if (e.which < 0x20) { // e.which < 0x20, then it’s not a printable character // e.which … Read more

bind a jquery function to fancybox .close() event

*Update: * Please take a note of @mathoiland’s answer, “It looks like Fancybox 2 deprecated the onClosed callback. It now uses afterClose.” if you are using FancyBox 2.x Pass the onClosed option to the fancybox function. i.e: $(“<YOUR-SELECTOR>”).fancybox({ onClosed: function() { $(‘#sub_cont’).hide(250, function() { $(‘#IDsearchform input’).val(”); }); }) });

jQuery: Single button click, click event firing two or more times

Your problem may be happening because you are assigning the same handler to the click event multiple times. I suggest you check that the line where you assign the handler is not being called multiple times inadvertently. Another solution could be a call to unbind (deprecated 3.0) or off (superseeded) first: $(“#myButton”).unbind(“click”).click(myHandler); // deprecated $(“#myButton”).off(“click”).click(myHandler); … Read more

tech