Currently I have a textarea with an onkeypress event specified in the HTML tag. I am trying to capture this keypress and save it as a function that will be used to override it, as I want to add another condition to when it is run. Here is the code I am trying to implement.
$(document).ready(function(e) {
var defaultKeypress = $('textarea').keypress;
$('textarea').keypress(function(e) {
if (fieldsChanged) {
fieldsChanged = false;
}
else {
defaultKeypress(e);
}
});
});
The issue I am having is with IE 7 & 8. Both fire the original keypress (even if "defaultKeypress(e);" is commented out) and the new keypress are firing. (Original first, then new). Other than removing the onkeypress attribute from the textarea tag (I can't do this because if how the code is generated), is there a way to disable that original keypress from firing?
Thanks! Nutzy