I added the script below to a JSF application, the page in question contains a few popup windows with forms that get submitted event when invisible when the user is pressing enter while in a input-field on the base page.
Developing with Chrome this works, but Firefox doesn't supply the event's srcElement.id
fields.
What would be the correct (and browser independent) way to filter the fields?
$(document).ready(function() {
$("form").bind("keypress", function(e) {
var code = e.keyCode || e.which;
if (code == 13) {
// Allow return in multi-line text controls
if ( e.srcElement.id == 'form:create:ctext' || e.srcElement.id == 'form:edit:etext' ) {
return;
}
// Disable Submit on return
e.preventDefault();
}
});
});