I know this is beginner stuff but why is it that when I run this
validation my form still gets submitted. Can someone explain what I'm
doing wrong. I don't quite understand how the return true/false works
with the forms. Here is what I have
<?php
if ((isset($_POST["MM_Upload"])) && ($_POST["MM_Upload"] == "form1")) {
//do this
header("Location: Page.php");
}
?>
<script>
function UploadImage( f ){
if(f.userfile.value.length < 1)
{
f.bUpload.disabled = false;
f.bCancel.disabled = false;
f.bUpload.value = 'Upload';
alert("Please select a file to upload!");
f.userfile.focus();
return false;
}
else {
f.bUpload.disabled = true;
f.bCancel.disabled = true;
f.bUpload.value = 'Please Wait...';
//f.submit();
return true;
}
}
</script>
<form action="<?php echo $editFormAction; ?>" method="POST"
enctype="multipart/form-data" name="form1" id="form1" onSubmit="return
UploadImage(this);">
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="25">
<input name="userfile" type="file" class="control" id="userfile"
size="40">
<input name="Submit" type="submit" class="control" id="bUpload"
value="Upload" />
<input name="bCancel" type="button" class="control" id="bCancel"
onClick="MM_goToURL('parent','MyRecipes.php');retu rn
document.MM_returnValue" value="Cancel">
<input name="MM_Upload" type="hidden" id="MM_Upload" value="form1">
</form>