JavaScript topics, Submitting Enter key

Submitting a Form by Enter key
Post on March 16th, 2007
Depending on the browser type and configuration, pressing the Enter key while in a form does not always submit the form. Sometimes, for instance, the button that submits the form resides in another frame. In that case, adding a bit of JavaScript to ensure that the Enter key sends the form data, as well, comes in handy.
All that is necessary to implement for that function is a standard key listener: Keyboard events are not part of DOM Level 1 or Level 2, but are still implemented in recent browsers.
Accessing the event differs from the usual approach (window.event in Internet Explorer; the event as the automatic parameter of the function in all other browsers). But then, the keyCode property returns the ASCII code of the key, which can then be processed, as in the following example:
The key code for the Enter key is 13, so when this code is found, the form is submitted:
function checkKey(e) {
 
var key;
 
if (window.event) {
 
key = window.event.keyCode;
 
} else {
 
key = e.keyCode;
 
}
 
if (key == 13) {
 
document.forms[0].submit();
}
 
}
 
window.onload = function () {
 
document.forms[0].elements[“field”].onkeydown = checkKey;
}
From JavaScript topics

Leave a Reply
Name (required): Email (required): Website: Comment:
Note: XHTML is allowed. Your email address will never be published.
ActionScript 3.0 Basics for Designers
Understanding T-SQL using SQL Server
jQuery: Enhancing Web Development
Beginning AJAX ASP.NET Web Development
Database Development with ASP.NET
Intermediate ASP.NET Web Development
Beginning ASP.NET Web Development
Unobtrusive JavaScript Programming
JavaScript Basics

Registration for the September session (9/6/2010) will open on August 1st. The next session will start in September for my online classes hosted at http://www.lvsonline.com.
The Understanding WordPress courses run continuously and is paid through this site, so you can register any time.
Recent Posts
·ActionScript 3.0 Basics for Designers Class
·Understanding T-SQL using SQL Server Class
·jQuery: Enhancing Web Development Class
·Beginning ASP.NET AJAX Web Development Class
·AJAX 101 ” part 2
·JavaScript Magazine ” JsMag
·AJAX 101 ” part 1
·Database Web Development with ASP.NET Class
·Creating Even Faster Websites Podcast
·Understanding WordPress: Top Ten SEO Tips
·Understanding WordPress Online Courses
·Interview with Lorelle VanFossen
·JavaScript: The Basics Class
·Interview with Christian Heilmann
·PHP Style Switcher
Categories
·Adobe Flash (9)
·Ajax (4)
·ASP (2)
·ASP.NET (8)
·CSS (10)
·Dreamweaver (2)
·Fun (1)
·HTML (3)
·Interviews (6)
·JavaScript language (1)
·JavaScript topics (24)
·jQuery (6)
·Online classes (11)
·PHP (8)
·Podcasts (9)
·SQL (2)
·Video tutorials (7)
·Web conferences (2)
·Web stuff (13)
·WordPress (2)
Popular tags
“John Resig” ActionScript 3.0 Adobe Flash Ajax Apache ASP ASP.NET blogging C# Christian Heilmann Class Classes and Training CSS Database DOM Dreamweaver Flash CS3 Functions Hover Effect Interview JavaScript topics Jeremy Keith jQuery Learning libraries LVSOnline LVSOnline classes MySQL Online classes PHP Podcast Presentational Markup presentations SQL Server Styling tutorials video tutorials Web conferences Web Design Web Development WordPress XHTML XML XSLT Yahoo
Notable Blogs
·Aaron Newton
·Airtight Interactive
·Ajaxian
·Alex King
·Andy Budd
·Andy Clarke
·Andy Rutledge
·Bob Easton
·Brian Goldfarb
·Cameron Adams
·Cameron Moll
·CartoonSmart
·Chris Heilmann
·Dan Simard
·Dan Wahlin
·David Stiller
·Dustin Diaz
·Eric Meyer
·Geoff Stearns
·Independents Hall
·Jacob Seidelin
·James Edwards
·Jeremy Keith
·John Musser
·John Resig
·Jonathan Christopher
·Jonathan Snook
·JSMag
·Justin Palmer
·Matt Snider
·Michael Mahemoff
·Milan Negovan
·Molly Holzschlag
·Nate Koechley
·Paul Boag
·Peter-Paul Koch
·Robert Nyman
·Roger Johansson
·Samuel Ryan
·Sarah Lacy
·Saul Rosenbaum
·School of Flash
·Scott Andrew LePera
·Scott Guthrie
·Scott Mitchell
·Scott Schiller
·Shaun Inman
·Steve Sharrock
·Tina Su
·Understanding WordPress
·WebAppers
About
This site started back in September 2005 as an online resource for my training at a local computer club. The material was based upon taching people how to do web programming with JavaScript.
It then expanded over the years to offer online classes (in JavaScript and ASP.NET) to anybody as well as more of a wider range of topics inlcuding HTML, CSS, PHP, ASP.NET, Flash, etc.
Feel free to contact me if you have any question on the online classes I offer or material covered.
Flickr

Search

Aly Chiman

Aly Chiman is a Blogger & Reporter at AlyChiTech.com which covers a wide variety of topics from local news from digital world fashion and beauty . AlyChiTech covers the top notch content from the around the world covering a wide variety of topics. Aly is currently studying BS Mass Communication at University.

Leave a Reply

Your email address will not be published.