Sanitizing Input Fields on the Client Side

Some example code for stripping out all non word characters. So only letters, underscores/spaces, and numbers. This would not be good for email sanitization, but could be good for other input fields. var search_term = $(‘.search_tag_input’).val(); // strip tags search_term = search_term.replace(/(<([^>]+)>)/ig,”"); //spaces as underscores search_term = search_term.replace(‘ ‘, ‘_’); //remove nonword characters (and underscores) [...]

The Best Way to Handle Scroll Events

John Resig has an excellent post on his blog about scroll events, efficiancy, and how that recently affected twitter. Below is some example code he wrote for working with scroll events.