+ Start a Discussion
Lokeswara ReddyLokeswara Reddy 

How to control command buttons when 'Enter' button clicked

Hi All,

There a VF page to search on Accounts, the page has 'Search' and 'Cancle' buttons, after filling data in search field and if you click 'Enter' button it won't work, the user has to click manually on 'Search' button, when clicked it reloads the page and shows progress bar till the resulsts displayed. 
Now there is a new requirement to have a new button 'Create New Account' in the VF page to redirect to new Account edit page by copying the data from search fields, Every thing works fine, but if user clicks 'Enter' button after filling search fields by defaults it takes the user to New account page!
Is there any way that we can controle this? on 'Enter' click it should invoke 'Search' button else NO action,

<apex:commandButton action="{!search}" value="Search" id="SearchBt" status="processingStatus" reRender="resultPanel,errorPanel"/>
<!--  <apex:commandButton action="{!search}" value="Search"/> -->
<apex:commandButton action="{!reset}" value="Reset" status="processingStatus" reRender="resultPanel,errorPanel,searchPanel"/>
<apex:commandButton action="{!redirectToNewAccountPG}" value="Create New Account"/>

I have tried Line#2, the Enter button has invoked 'Search' button, but it did not show the search bar and more over it reloads entier page and not just the search results.

Any thoughts on this? Thanks in advanc