views:

24

answers:

1

Notes on environment: JSF 1.1 using Infragistics component library.

I'm using the following Javascript to attempt to prevent an 'Enter' keypress from submitting a form.

function disableEnterKey(e){     
     var key;      
     if(window.event)
          key = window.event.keyCode;
     else
          key = e.which;
     return (key != 13);
}

Then in the JSP, I have:

<h:inputText id="an_id" value="#{bean.value}" 
             onkeypress="return disableEnterKey(event);" />

This seems to work flawlessly in Firefox and Google Chrome. I don't understand why it doesn't work with IE8. I'm stumped.

I've tried using a Tomahawk <t:inputText/>, but that doesn't make a difference.

I've tried putting something in the onkeypress handler for the parent <h:form> and/or the <body> element, but that doesn't seem to help either. And, I've tried using the onkeydown, but haven't seen a difference with that, either.

The differential diagnosis that I think I have come up with is that it may have something to do with the Infragistics library. IG does add quite a bit of scripting to pages, but I'm not solid on how to debug Javascript effectively with IE8. This would be no problem to poke through with Firebug on FF, but I'm a bit stumped.

Anyone have a similar experience? Know of a fix?

A: 

Hi,

weird thing, because it works for me in IE8 and in FF only this way:

var key;
if(window.event)
{
    //IE
    key = window.event.keyCode;
}
else
{
    //FF
    key = e.keyCode;
}
lkdg