[UFO Chicago] html forms and javascript

Sean Neakums sneakums@ufo.chicago.il.us
Mon, 30 Sep 2002 18:33:36 +0100


Disclaimer: I have no real experience with this stuff. 

Observation: I prefer to do validation on the server, since that works
in all situations.

Anyway.

commence  Robert B. Moses quotation:

> <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();
> }
> // -->

Did you close the <script ...> element with a </script> in the
original?  And you put the whole thing inside the <head> element,
right?

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

Might need to be onClick="javascript:validate();" there.

> 	<input type="reset" name="cancel1" value="Cancel" />
> </form>

-- 
Sean Neakums - <sneakums@ufo.chicago.il.us> --- --- -- -
Director of International Operations, UFO Chicago - -- -
http://ufo.chicago.il.us/ --- ------ ----- ---- --- -- -