I have a field and want to prevent some illegal characters while showing the user as he types. How can I do this in follow example?
$('input').bind("change keyup", function() {
var val = $(this).attr("value");
/*
if (val --contains-- '"') {
$(this).css("background", "red");
val = val.replace('"', "");
$(this).attr("value", val)
}
*/
$("p").html(val);
});
EDIT: I should put the illegal characters in an array
var vowels = new Array('"', "<", ">", "&");