-
Hi!
I have this form on my page, with an "onsubmit" function". Now I don't use a submit button to have the form submitted, but an image. So the code goes something like this (the file validationfunctions.js contains a function called validatecontents() ):
<script language="javascript">
<!--
function submittheform()
{
document.myform.submit();
}
//-->
</script>
<script language="javascript" src="validationfunctions.js">
</script>
.
.
<form name = "myform" action="nextpage.asp" onsubmit="validatecontents()">
.
.
<a href="javascript:submittheform()"><img src="image.jpg"></a>
</form>
Now when I click the image, it submits the form, without running the validatecontents-function first. Why? And how can I make it so it DOES run that function first?
Many thanx! :)
-
try this
<form name = "myform" action="nextpage.asp" OnSubmit="return validatecontents()">
Also return true from the function validatecontents()
-
Hi!
I'm sorry, in my page the form declaration is like the solution you gave, but when submitting the problem here, I just typed the code in from heart, and forgot to type the return statement. :)
So... the problem remains unsolved..
-
Why not call the validation function from your submittheform() function?