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 IV

by Heidi Brumbaugh

submit vs. onSubmit Humbug

 <HTML> <HEAD> </HEAD> <BODY> <FORM NAME="Test" METHOD=post ACTION="javascript:alert('At action');" onSubmit="alert('At onSubmit() Event');"> Click the pretty button to submit form. <INPUT NAME="id" TYPE="hidden"> </FORM> <A HREF="javascript:document.Test.submit()"> <IMG SRC="submit.gif" WIDTH="87" HEIGHT="34" BORDER="0"></A> </BODY> </HTML> 

The problem here is the little detail that the documentation doesn't mention: The submit method and the onSubmit event are mutually exclusive. When you think about it, this does make sense: the whole point of onSubmit is to give you a chance to verify the form data. But if you're programmatically submitting the form, you have that opportunity anyway. Rather than submitting the form with the anchor tag:

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

and then verifying with

onSubmit="return ValidateFields();"

[Jump to Part 5]


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


HTML5 Development Center


Recent Articles