Hi, first of all sorry if this has come up before, but I couldn't find it anywhere.
I have a working php form which submits data on submit. I need to verify the input fields to ensure they are not empty. I know i need a javascript function to run this check.
I am just having problems running the javascript before the form is submitted.
Any helps would be grand.
Javascript code:
<script language="JavaScript" type="text/javascript">
<!--
function verify ( form )
{
if (form.email.value == "") {
alert( "Please enter your email address." );
return false ;
}
else {
return true ;
}
}
//-->
</script>
Here is some of the code, with one of the required fields, email.
<form method="post" name="Comment Form" action="PHP/comment.php" target="_self">
<table border="0" name="pageid" id="commentform">
<tr>
<td><div align="right">Email: (Required)</div></td>
<td><input type="text" name="email" size="30" /></td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" name="submit" value="Submit" />
<input type="reset" name="reset" value="Reset" />
</td>
</tr>
</table>
</form>