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) [...]