Jquery .submit event not capturing

I’m trying to do a form validation…however, i can’t get the submit event to work.
So I tried to alert a message when the form submits. But the form submits without going through the submit function.

Heres the code

embeded in validateContactForm.js

	return false;

link the external js scripts in the head

<script src="jquery-1.3.2.min.js" type="text/javascript" ></script>
<script src="validateContactForm.js" type="text/javascript" ></script>

the form…

<form method="post" action="" id="form1">
<input type="image" src="images/btn_submit.png" alt="Submitimg" value="submitimg">

what could be the problem?
btw, linking external js script is using type=“text/javascript” or language=“javascript”? anyway i tried both and it doesn’t work too.

Web browsers process a web page from the top to the bottom. As javascript is encountered, whether it be inline, or external, it is executed.

So, you cannot expect this to work

<b id="foo">hi</b>

But this would work

<b id="foo">hi</b>

If that’s not your issue, check the error log.

By using type=“text/javascript”

The language attribute was deprecated when HTML 4.01 came out, in 1999, some 11 years ago, so please don’t use the language attribute. The idea behind it was initially interesting because you could target sections of scripts to different versions, but it ultimately it became became too difficult to control.

thanks for the replies. great, i moved the external link to the end of the document and it worked!

but its weird though since the page was fully loaded before the submission. i thought it wouldn’t have problem reading from the form. no errors were returned either.

In order to assign a function as an event handler to an element, the element must exist.

jquery has a live() method that doesn’t actually assign the event handler to the element, and so you can use that before an element exists.

jquery also has a ready() method, that will execute functions after the dom is loaded(after the browser finishes parsing all the html), regardless of where in the page you call the ready() method.

Your probably going to have a tough time if you try to learn a javascript library like jquery, without first learning javascript.

It’s like learning to run before you can walk! :injured: