WebReference.com logo
tip archive  •   about  •   sitemap  •   contact  •   jobs  •   write for us  •   subscribe


[next]

Bring Your Forms to Life With Javascript

By Kris Hadlock

Digg This Add to del.icio.us

UNIX System Administrator - SUN Solaris, Veritas, EMC, Shell Scripting, SAN (NYC)
Next Step Systems
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume

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, shown below.

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.


[next]

Recent Articles

WebReference.com site name
Use Web Caching to Make Your Web Site Faster
Creating an Online Shopping Cart Mechanism in PHP
Log JavaScript Errors Using an AJAX-driven Web Service
internet.com site name
Configuring Granular Settings for a Database Level Audit
The Perils of a Web 2.0 Transition on Your Business Processes
Facebook Redesigns Site —Again — Nears 400M Mark



The Network for Technology Professionals

Search:

About Internet.com

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