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.
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.
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.