WebDeveloper.com �: Where Web Developers and Designers Learn How to Build Web Sites, Program in Java and JavaScript, and More!   
Web Developer Resource Directory WebDev Jobs
Animated GIFs
CSS
CSS Properties
Database
Design
Flash
HTML
HTML 4.01 Tags
JavaScript
.NET
PHP
Reference
Security
Site Management
Video
XML/RSS
WD Forums
 Client-Side
  Development

    HTML
    XML
    CSS
    Graphics
    JavaScript
    ASP
    Multimedia
    Web Video
    Accessibility
    Dreamweaver
    General
    Accessibility
    Dreamweaver
    Expression Web

    General

 Server-Side
  Development

    PHP
    Perl
    .NET
    Forum, Blog, Wiki & CMS
    SQL
    Java
    Others

 Site Management
    Domain Names
    Search Engines
    Website Reviews

 Web Development
  Business Issues

    Business Matters

 Etc.
    The Coffee Lounge
    Computer Issues
    Feedback




JavaScript for the Holidays Part V

by Heidi Brumbaugh

You could just fold everything together with:

<A HREF="if (ValidateFields()) javascript:document.Test.submit()">

Alternately, you could submit the form inside the ValidateFields() routine.

Form Field Example Rings False

And speaking of form field verification, an alert reader has caught a bug in my form verification example . I hate that.

Heidi, I have enjoyed your Javascript tutorials on www.webdeveloper.com, but I have a problem with the section: Client-Side Form Verification with JavaScript I have tested this script using Netscape 3.0 & IE 4.0, and both have the same problem. If you enter incorrect information in the form fields and submit the data, the script WILL generate the instructed dialog box BUT the form data will submit anyway. My understanding of the valid = 0 statement is that if the data is not valid, the dialog box would open and the user would be returned to the form...

Am I missing something here???

Joel Oelfke

No, I'm missing something. I made the mistake of assuming that 0 can be used to mean false in JavaScript, as it can in Basic, C, and other scripting languages. It turns out that, no,

return 0

with

if (valid) return true; else return false

and the example works.

Happy Holidays!


Heidi Brumbaugh has been a writer and editor in the computer publishing industry for ten years. She is currently making the transition to publishing on the Internet, a pursuit ranging from content development to JavaScript programming. Like everyone else with a modem, she is trying to figure out how to strike gold on the Web, or at the very least, support her surfing habit. Feel free to visit her home page.
Web Developer® Site Feedback
Web Developer®
Copyright © 1999-2001 internet.com Corp.
All rights reserved.



HTML5 Development Center


Recent Articles