![]() | |
#1
| |||
| |||
|
#2
| |||||||
| |||||||
|
|
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" |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
Thanks for the great explanation. What happens is when I submit with nothing in the file field it prompts me but it must be still submitting because my php code is seeing that it is submitted and I'm getting redirected. Thats why I posted the php. I'm thinking it is still being submitted even when the scripts is saying not to |
![]() |
| Thread Tools | |
| Display Modes | |
| |