function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SwapnilSwapnil 

Pressing enter on form with commandButton not working in IE

Hi,

 

    Pressing enter key on form with commandButton not working in IE, but it works fine in firefox. Its a search box and when I type something I want to hit enter to initiate the search. Any pointers...that I can try...

Best Answer chosen by Admin (Salesforce Developers) 
SargeSarge

Hi Swapnil,

 

   Try the following code in input text (Assuming you have "Go" button for search)

 

 

<apex:inputText value="{!searchKey}" onkeyup="initiateSearch()"/>
<apex:commandButton id="gobtn" value="Go" action="{!performSearch}"/>

<script type="text/javascript">
    function initiateSearch(){
var goBtn = document.getElementById('{!$Component.gobtn}');
if(window.event.keyCode == 13){
goBtn.click();
}
}
</script>

 

 

 

window.event.keyCode == 13

All Answers

SwapnilSwapnil

Now I tried using inputText and onKeyEvent, even this worked in firefox but not in IE

SargeSarge

Hi Swapnil,

 

   Try the following code in input text (Assuming you have "Go" button for search)

 

 

<apex:inputText value="{!searchKey}" onkeyup="initiateSearch()"/>
<apex:commandButton id="gobtn" value="Go" action="{!performSearch}"/>

<script type="text/javascript">
    function initiateSearch(){
var goBtn = document.getElementById('{!$Component.gobtn}');
if(window.event.keyCode == 13){
goBtn.click();
}
}
</script>

 

 

 

window.event.keyCode == 13
This was selected as the best answer
SwapnilSwapnil

Hey Thanks, this worked..

nagalakshminagalakshmi

Hi Sarge,

 

I am also facing the same issue. I have a custom object. i am override the 'view' link with visual force page. In my visual force page i have a  command link. when i click on the command link it shows the list of child records. It is worked properly in google chrome and mozilla firefox. But in IE it is not working. when i click on the command link its just refresh the screen and displays the same screen.it does not open the child records panel. Please help me out how to solve this.

 

Thanks,

Lakshmi