[UFO Chicago] html forms and javascript

Robert B. Moses robert.moses@helioslogic.com
Mon, 30 Sep 2002 12:19:43 -0500


since we had been talking about google and html i have a "i can't 
remember how the hell this is supposed to work" question:

I have an html doc with a form.
i want to call a javascript function when the submit button is pressed 
and THEN proceed with the form submission, for example:

<script type="text/javascript" language="JavaScript">
<!--
function validate() {
	if (document.forms[0].name1.value == "") {
		alert(Please Enter your name!);
		document.forms.name1.focus();
		return:
	}
	document.forms[0].submit();
}
// -->

blah blah stuff
<form method="post" action="doit.php">
	Name :
	<input type="text" name="name1"/>
	<input type="button" name="submit1" value="Submit"
		onClick="validate();"/>
	<input type="reset" name="cancel1" value="Cancel" />
</form>

SO.....
every time i try that....the button does nothing, and the form is never 
submitted. Now i can make the submit button work by using <input 
type="submit"> but that doesn't allow me to define extra behavior????

this should be simple!!!!

--
Rob Moses