• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Prevent 'enter' key from submitting form

Prevent 'enter' key from submitting form 12 years 9 months ago #14228

  • KevenM
  • KevenM's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 14
I've noticed in a couple of instances where form respondents hit the enter key after filling in the first field - which submits the form without allowing them to enter the rest of the fields.

Is there a way to prevent this from happening? (ie., 'enter' does NOT trigger the <submit> button)
The administrator has disabled public write access.

Re:Prevent 'enter' key from submitting form 12 years 8 months ago #14292

  • andreic
  • andreic's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 722
  • Thank you received: 59
Hello,

This can be achieved, but it will require some custom scripting, please try adding the following code in the "CSS and Javascript" tab:
<script type="text/javascript">
 
function stopRKey(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
}
 
document.onkeypress = stopRKey;
 
</script>
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
The administrator has disabled public write access.
The following user(s) said Thank You: contact332, hamidweb69, ls-arch

Re:Prevent 'enter' key from submitting form 12 years 8 months ago #14520

Where do you put the function? Does it need to assigned to the send button?

It works because I've deleted the other function which was already there in CSS & JavaScript. Enter doesn't do anything anymore.

What do I need to do to use multiple functions?
Last Edit: 12 years 8 months ago by alice24springs. Reason: Got it to work but with some cons
The administrator has disabled public write access.

Re:Prevent 'enter' key from submitting form 11 years 8 months ago #18325

  • patrick.jackson2
  • patrick.jackson2's Avatar
  • OFFLINE
  • Fresh Boarder
  • KPS - Joomla Consultant Melbourne Australia
  • Posts: 12
  • Thank you received: 6
Alice24springs,

Just saw your post while grabbing the code for a form I needed it for.

You can put multiple functions inside the Javascript area either by bracketing each one in <script></script> or just place each one one after another inside the one set of <script></script> tags.

Patrick
The administrator has disabled public write access.
The following user(s) said Thank You: ls-arch

Re:Prevent 'enter' key from submitting form 7 years 10 months ago #35157

andreic wrote:
Hello,

This can be achieved, but it will require some custom scripting, please try adding the following code in the "CSS and Javascript" tab:
<script type="text/javascript">
 
function stopRKey(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
}
 
document.onkeypress = stopRKey;
 
</script>

hi
its very useful code
how can i use this code for autotab? i want a JavaScript cod for Make enter key behave like tab key

its very useful for filling forms by Baroda scanner...
The administrator has disabled public write access.

Re:Prevent 'enter' key from submitting form 1 year 6 months ago #42262

  • ls-arch
  • ls-arch's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
Did you ever get a response on how to set up the Enter key to behave as the Tab key? I would also like to know how to do that.
Thanks.
Last Edit: 1 year 6 months ago by ls-arch. Reason: corrected punctuation
The administrator has disabled public write access.

Prevent 'enter' key from submitting form 8 months 4 weeks ago #42870

  • duncan
  • duncan's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 19
  • Thank you received: 1
Hello,

I know this is an old post, but I'm looking to solve this same problem, ie disable the enter key for submitting a form.

I have tried adding the javascript code into the javascript panel, but it's not working.

Should this code still work?

Any help greatly appreciated.

D
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!