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

Software Developer / Programmer - Need 2 people
Next Step Systems
US-IL-Des Plaines

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
XML and PHP Simplified
Creating a ASP.NET Contact Form
Data Filtering with PHP
internet.com site name
Intel to Host Live Nehalem Q&A
12 Tips to Troubleshoot Network File-Sharing
10 Tips for Selling on Kijiji


internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs