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 III

by Heidi Brumbaugh

submit vs. onSubmit Humbug

I had a few questions about form verification. This is a good one from John Romero, who wants to replace the standard form button with one of his own design:

As per HTML documentation, a form can be validated prior to execution by using the onSubmit() method. The onSubmit() method should return a logical value which if true would execute the action.

For example:

onSubmit="return ValidateFields();"

If ValidateFields() returns a true, the form would go on to execute its action, ie:

ACTION="RecordData.html"

Since I have placed an image instead of a button, my HREF submits the form via a javascript call.

HREF="javascript:document.Test.submit();"

As stated in documentation and according to my logic, once the user clicks on the image, it should trigger a form execute. The onSubmit() method should execute next and based on its "return" value, the form should execute its action.

Guess what!, this approach never ever reached the onSubmit() method.

Here's the sample code.

[Jump to Part 4]


Web Developer® Site Feedback
Web Developer®
Copyright © 1999-2001 internet.com Corp.
All rights reserved.


HTML5 Development Center


Recent Articles