Can't call javascript from an HTML form
Posted: Thu Jul 26, 2007 7:33 am
I have the following code which seems to not call the javascript function from within the form. However if the form closes before the html buttons, it works properly. Why can I not get the functions to call from inside the form?
This doesn't work.
This does work.
Code: Select all
<script type="text/javascript">
<!--
function join()
{
if (document.form1.password.value.length < 1) {
alert("enter your details");
return false;
}
document.Form1.action = "http://example.com/"
}
//-->
</script>
Code: Select all
<form name='form1' method='post' >
<input name='password' type='password' id='password'>
<input type='submit' name='join' id='join' value='Join' OnClick='return join();'/>
</form>
This does work.
Code: Select all
<form name='form1' method='post' >
<input name='password' type='password' id='password'>
</form>
<input type='submit' name='join' id='join' value='Join' OnClick='return join();'/>