I have an input box which invokes a button action when Enter key is pressed.
<h:inputText value="#{myBean.fname}" id="name" onkeydown="callClickEvent(event);"></h:inputText>
**Js function is**
--------------
function callClickEvent(event){
if (event.keyCode == 13 || event.which==13) {
document.getElementById('dataForm:btnA').click();
}
}
In my xhtml i have two button
<h:commandButton action="#{myBean.actionPerform}" id="btnA""/>
<h:commandButton action="#{myBean.updateAction}" id="btnB"/>
now the problem is , this code runs fine in chrome and firefox but not working as expected in IE9;
in IE 9 , when I hit enter key it invokes both buttons action.
suggested solution in stack overflow were: (1) add type ="button" (2) add e.preventDefault() inside javascipt function.
when i add type="button", action method dosen't invoke when i click second button.
and when i add e.preventDefault(), it does'nt let me type anything side input box.
any help would be appreciated.