JavaScript
  Home arrow JavaScript arrow Page 4 - Introducing Key Concepts for Form Validati...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

Introducing Key Concepts for Form Validation with the DOM
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 5
    2006-10-24

    Table of Contents:
  • Introducing Key Concepts for Form Validation with the DOM
  • Creating an old-fashioned form validation mechanism
  • Using the DOM for validating online forms
  • Removing error messages from the web page
  • Completing the validation script

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Introducing Key Concepts for Form Validation with the DOM - Removing error messages from the web page


    (Page 4 of 5 )

    As you learned in the previous section, the "hideError()" function is called up each time the user changes a value entered in a specific input box. We do this to remove from the pertinent web page the error node that was originally appended to the document tree when a failure comes up.

    Now that you know how the "hideError()" function works, let me show you its corresponding definition. It is as follows:

    // remove error messages from the web document function hideError(){        this.parentNode.removeChild(this.errorNode);        this.errorNode=null;        this.onchange=null; }

    Although the signature for the above function is very short, its functionality is indeed remarkable. As you can see, the "hideError()" function removes from the document tree the corresponding error node that was originally appended to a specific offending form field, in addition to disabling its "onchange" error handler.

    As you'll realize, we eliminate this event handler for a simple reason: since the validation script assumes that the user has corrected the offending value entered in the form, this trigger shouldn't be active any longer. Sounds fairly logical, right?

    At this point, you've learned how to display and remove error messages via the DOM, which is considerably more elegant than using silly alerts. Therefore, the next topic that I'll discuss in this tutorial will be the definition of a classical form validation function, responsible for triggering the functions that you saw before when a particular user input is considered invalid.

    Want to see how this data verification will be created? Then go ahead and read the following section. I'll be there, waiting for you.

    More JavaScript Articles
    More By Alejandro Gervasio


       · In this first part of the series, you'll learn how to use the DOM, in order to...
       · Hi:I would have loved to read your article, but when I increase the text size...
       · Hi, tedd. All of our sites are designed for 1024x768 resolution. The...
       · Hello Ted,Thank you for your interest on my DOM article. As Robert gently said...
     

    JAVASCRIPT ARTICLES

    - More on JavaScript Array Objects
    - Methods of the DOM Location Object
    - The DOM Location Object Properties
    - Handling Remote Files with JavaScript Click ...
    - Using Click Interceptions with a Database-Dr...
    - Using JavaScript Click Interceptions in an I...
    - Using Click Interceptions with JavaScript
    - QuickSort in Action
    - Quicksort
    - Using Mod_Security to Protect Your Server
    - Detecting and Countering Server Intrusions
    - Securing Your Web Server
    - Building a Secure Web Server
    - Protecting the Server
    - Book Review: Learning the Yahoo! User Interf...


     
    Best Practices for Windows Vista Migration Presentation
    Dell and Microsoft recently held a series of face-to-face seminars entitled, &qu....

     
    Creating a Culture for Code Reuse
    If you oversee development teams you know that like it or not proprietary and ex....

     
    Keys to Web Application Acceleration: Advances in Delivery Systems
    Accelerate Web apps by up to 5x. Ensure significantly faster access to the Web a....

     
    Optimizing Application Monitoring
    Tired of finding out from your customers that you're offline? This white paper e....

     
    Solaris to Solaris Migration -- Migrating applications from Sun SPARC to Dell PowerEdge R900
    This comprehensive Migration Guide reviews the approach that Principled Technolo....

     





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT