I want to validate a form with a function, to send the data to the server (and insert into the database) and then go to the next page. I want to do it with a hyperlink, and now I know four possibilities to validate a form. Which is the best and why?


1.
<form action="next_page.asp" onSubmit="return checkMail(this.form)" method="post">

<input type="submit" value="Submit">
</form>



2.
<form>

<a href="next_page.asp" onClick="return checkMail(this.form)">To send data</a>
</form>



3.
<script language="JavaScript">
<!--
function checkMail(form)
{
for (var = i; i < form.elements.length; i++ {
if (form.elements[i].value == "") {
alert("Fill out ALL fields.")
return
}
}
form.submit()
return
// -->
</script>
}


<form>
<a href="next_page.asp" onClick="return checkMail(this.form)">To send data</a>
</form>



4.
<form action="next_page.asp" method="post">
</form>

<a href="javascript:document.forms[0].submit()">To send data</a>