HTMLGoodies
The ultimate html resource
Earthweb.com


About the Double-Underlined Links


Become a Partner






internet.commerce















HTML Goodies : Beyond HTML : Javascript: Bring Your Forms to Life With JavaScript


Web Development Daily Newsletter


Other Related Newsletters

Bring Your Forms to Life With JavaScript


By Kris Hadlock

In this article we'll take a look at how to prevent errors in your forms and ultimately bring them to life through JavaScript. The source code for the samples used in this article can be downloaded here and a live example can be viewed here. Now let's add some life to those old forms.

Creating a basic Web form

We'll start by creating a basic registration form with a few common form elements. We'll create an HTML page and add the the registration form code from listing 1.

The code from listing 1 will allow us to post data to a server and register a user. It could also display any errors or warnings based on server-side results, but this is equivalent to asking your users to complete a form and hope that it will be sent successfully. There's really no reason to make a user wait when we can provide them immediate feedback and prevent issues from occurring rather than having to deal with them after the fact. Having said that, it would be useful to have a JavaScript object that allows us to validate all our forms without having to rewrite code everytime we create a new form. Let's take a look at how to accomplish this by creating a reusable JavaScript validation object and tying it to the form we just created.

Go to page: 1  2  3  Next  

Tools:
Add htmlgoodies.com to your favorites
Add htmlgoodies.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed



IT Management Networking & Communications Web Development Hardware & Systems Software Development Earthwebnews.com

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers