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
csbaacsbaa 

Custom button action fired when pressing ENTER

Hello Helpers

I  have a question  related to the behaviour  of a visual  force  page  when user  clicks  enter

I  have  a visual force  page  which  capture  some input  from the user  in  apex:inputField   elements
There are several  apex:inputField  elements  each  linked  to a record 

On the top of  the page I have a apex:commandButton

when user  clicks  on the button  I create  several  records  in the background

BUT,  my  problem is that  any  time user  add a value  into one  of the apex:inputField   text  box the press ENTER and  the system  interpret  it  as a button action

I  want to disable  it
I  want to  button action to be fired  only  when user click on it

I  hope  it  is possible


Thanks in advance
csaba
Shaijan ThomasShaijan Thomas
<script type='text/javascript'> 
		function runOnEnter(ev) { 
			if (window.event && window.event.keyCode == 13 || ev.which == 13) { 
				searchAccRecs(); return false; 
			} else { return true; } 
		} 
		</script>

You can try this
Shaijan Thomas
Dushyant SonwarDushyant Sonwar
http://stackoverflow.com/questions/13643706/is-it-possible-to-set-an-html-button-as-default-inside-a-form
Use this script to override default enter save button...
csbaacsbaa
Hello  Shaijan Thomas

Thanks  for replyoing to my  questio regarding  buttons

As I understood  from your  code  below  this is  an event handler  function
But how  can I  link this  event handler  with  my  buton   or  inputfield  controls?

When this function is  fired?
I  inserted  the code inside  my VF page  but  nothing happened


<script type='text/javascript'> function runOnEnter(ev) { if (window.event && window.event.keyCode == 13 || ev.which == 13) { searchAccRecs(); return false; } else { return true; } } </script>
 
Shaijan ThomasShaijan Thomas
For command button use accesskey and input field use onblur event.
Thanks
Shaijan Thomas