Disable Enter Button On Forms

Sometimes it can be annoying when you're filling out a form and hit return, causing the form submit when you didn't mean for it to. This script makes pressing return in a form take you to the next field instead of submitting.

About This Script

Place the code at the bottom of this page inside the <head> section of your page. Then add the "disableReturn" class to any form on the page you wish for this to apply to.

Demo

Code

<!-- jQuery is required if you're not already using it --> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <!-- Disable return provided by http://www.top-site-list.com --> <script> $(document).on('keydown', 'form.disableReturn :input:not(textarea)', function(e) { if (e.which == 13) { // Don't submit e.preventDefault(); e.stopPropagation(); // And go to the next input var inputs = $(this).closest('form').find(':input'); inputs.eq(inputs.index(this) + 1).focus(); return false; } }); </script>
More scripts

Do you want to expose your site to millions?
Do you want to be ranked higher in Google?
Do you want to be known as the best site in your niche?

Then look no further. Add your site in 3 simple steps. Sign up, Add your site and Start receiving votes! It only takes 10 seconds!

Sign Up to Top Site List Planet Now!

Login with one of these social networks...

Sign in with FacebookSign in with TwitterSign in with Google+Sign in with Yahoo!Sign in with LinkedIn

or create an account with your email...

Login To An Existing Account