Skip to content

Instantly share code, notes, and snippets.

@johnhutchins
Created March 2, 2018 20:14
Show Gist options
  • Save johnhutchins/5403cd24c00549cfee6bb62073700948 to your computer and use it in GitHub Desktop.
Save johnhutchins/5403cd24c00549cfee6bb62073700948 to your computer and use it in GitHub Desktop.
InputCleaner = function() {
var start;
start = function() {
var onKeyUp;
onKeyUp = function () {
var text = $(this).val();
if (text.indexOf("<") !== -1 || text.indexOf(">") !== -1 || text.indexOf('"') !== -1 || text.indexOf("'") !== -1) {
text = text.replace(/</g, "");
text = text.replace(/>/g, "");
text = text.replace(/"/g, "`");
text = text.replace(/'/g, "`");
$(this).val(text);
}
};
$(document).on("keyup", "input.k-textbox", onKeyUp);
$(document).on("keyup", "textarea.k-textbox", onKeyUp);
$(document).on("keyup", "input[type='text']:not('input.k-textbox')", onKeyUp);
};
return {
start: start
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment