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
Naresh Krishna.ax1176Naresh Krishna.ax1176 

commandButton function on click of Enter key

Hi,

 

I have a input textbox and a command button in a page. When the user enters some text and clicks on the button i am invoking a method in Apex class.

 

The same functionality should be performed even when the user enters some text and clicks enter key.

 

I think this can be achieved using accessKey property of commandButton. I tried but it didn't worked.

 

Can someone please help me on this.

Best Answer chosen by Admin (Salesforce Developers) 
SeAlVaSeAlVa

have a look at 

http://cloud.sealvasoftware.com/2012/01/bindenterbutton_en/

 

(I'm starting a blog, that was my first Idea and needed more text, but as you need it, I have decided to publish it now)

 

If that solved your problem, please mark it as solved. 

 

Regards

All Answers

RonakPatel.ceRonakPatel.ce

Hi,

 

Have you tried with accessKey="Enter".. or Any other.

 

If this i right Answer then make it as a solution.

SeAlVaSeAlVa

have a look at 

http://cloud.sealvasoftware.com/2012/01/bindenterbutton_en/

 

(I'm starting a blog, that was my first Idea and needed more text, but as you need it, I have decided to publish it now)

 

If that solved your problem, please mark it as solved. 

 

Regards

This was selected as the best answer
ShaTShaT

Hi Naresh,

 

You can use onchange,onblur event on Input Text and use apex:actionFunction and call the function which you are calling on the button click.

 

 

Thanks 

Shailu

Naresh Krishna.ax1176Naresh Krishna.ax1176

It worked. Thanks a lot :)

ssrssr

I have two button like new event and search in vf page.

when i press enter key in the page opening New vf page  realted to new event button.

but here i need to stay search page only .

 

how can i do 

 

<td align="center" colspan="6"><apex:commandButton id="cmdSearchEvent" value="{!$Label.cEMS_Search}"
action="{!FunSearch}"/></td>

 

<td align="right" width="50%"><apex:commandButton id="cmdAddNewEvent" value="{!$Label.cEMS_New_Event}"
action="{!FunNewEvent}" />

 

any one can help onthis?

SeAlVaSeAlVa

Won't changing

<td align="center" colspan="6"><apex:commandButton id="cmdSearchEvent" value="{!$Label.cEMS_Search}"
action="{!FunSearch}"/></td>

 by

<td align="center" colspan="6"><apex:commandButton id="ENTER_BUTTON" value="{!$Label.cEMS_Search}"
action="{!FunSearch}"/></td>

 And using the component I mentioned on the URL provided some posts above provide the functionality you are looking for?

 

 

(Right now, pressing Enter calls an unwanted button (I believe that is the first button that has no reRender on it), and you want to trigger another button's action. Is this right? if so, check the link I'm talking about (cloud.sealvasoftware....)

 

Regards

ssrssr

Thank you very much for gave answer.

 

now iam going to implement this.

 

i will update on this scenario what happend to me .

 

 

SeAlVaSeAlVa

I'll wait for it ;)

ssrssr

Hi Selva,

 

yes , your code is working fine now.

 

thanks ,

 

keep posting solutions ..

 

sorry for the late reply.

 

i have two fields description and topic . these two fields are taking spaces by default. how can i restirct this situation in coding.

 

Thanks,

somesh.

 

ssrssr

Hi Selava,

 

Search Command button is not working in IE.

 

but its working in chrome and firefox good.

 

client asking need to check on IE also.

 

Could you please help on this.

SeAlVaSeAlVa

Which IE version do you have?

ssrssr

Latest version only iam using.

 

 

SeAlVaSeAlVa

I think it is fixed now.

just have to change the event that captures the key.

 

http://cloud.sealvasoftware.com/2012/01/bindenterbutton_en/