# Stopping enter from submitting a form

**URL:** <https://www.ruby-forum.com/t/stopping-enter-from-submitting-a-form/190224>\
**Category:** Rails\
**Created:** [June 17, 2010, 4:22pm UTC](https://www.ruby-forum.com/t/stopping-enter-from-submitting-a-form/190224 "2010-06-17T16:22:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brent\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Brent\_J](https://www.ruby-forum.com/u/Brent_J)\
**Post date:** [June 17, 2010, 4:22pm UTC](https://www.ruby-forum.com/t/stopping-enter-from-submitting-a-form/190224/1 "2010-06-17T16:22:25Z")

</div>

Hey all,

I’m working on a rails app that will be accepting input from a wide  
array of brandless barcode scanners. Is there anyway of making the  
return key tab to the next field instead of submitting the form? I  
know this is more of a javascript thing, but I just can’t get it  
solved.

---

<div class="post-metadata">

**Author:** ![Brent\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Brent\_J](https://www.ruby-forum.com/u/Brent_J)\
**Post date:** [June 17, 2010, 4:26pm UTC](https://www.ruby-forum.com/t/stopping-enter-from-submitting-a-form/190224/2 "2010-06-17T16:26:21Z")

</div>

I just read this up in a JS book. The submit button has actually 2  
events happening sequentially. The first one is an onClick and the  
second one an onSubmit. Both can return false and stop the execution  
of the action. If onClick returns false onSubmit will not be executed.  
I guess you could control your flow of execution based on what area of  
the page has the focus and only submit the form when you’re really  
done and switch focus to the next area of your page based on where you  
are when the submit button is pressed.

---

<div class="post-metadata">

**Author:** ![Brent\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Brent\_J](https://www.ruby-forum.com/u/Brent_J)\
**Post date:** [June 17, 2010, 4:27pm UTC](https://www.ruby-forum.com/t/stopping-enter-from-submitting-a-form/190224/3 "2010-06-17T16:27:00Z")

</div>

On 16 June 2010 21:20, Brent J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hey all,
> 
> I’m working on a rails app that will be accepting input from a wide  
> array of brandless barcode scanners. Is there anyway of making the  
> return key tab to the next field instead of submitting the form? I  
> know this is more of a javascript thing, but I just can’t get it  
> solved.

Did you try google? A search for  
javascript enter tab  
yielded many links that look potentially useful.

Colin

---

<div class="post-metadata">

**Author:** ![Brent\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Brent\_J](https://www.ruby-forum.com/u/Brent_J)\
**Post date:** [June 18, 2010, 3:41am UTC](https://www.ruby-forum.com/t/stopping-enter-from-submitting-a-form/190224/4 "2010-06-18T03:41:06Z")

</div>

Brent J. wrote:

> Hey all,
> 
> I’m working on a rails app that will be accepting input from a wide  
> array of brandless barcode scanners. Is there anyway of making the  
> return key tab to the next field instead of submitting the form? I  
> know this is more of a javascript thing,

You are correct.

> but I just can’t get it  
> solved.

Then I would suggest asking on a JavaScript list. You’ll get better  
answers.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
