Hi all

I have a form where a user can upload a file. I do a check to see if it's a zip file. If it isn't then its supposed to stop the file from being uploaded. Only thing is, the file still uploads regardless of getting the error or not.

How can I prevent the form from submitting the file if the error pops up?

function checkForm() {
	var filename = document.getElementById('file').value;
	var fileext = filename.substring(filename.lastIndexOf('.')+1);
	if (fileext != 'zip')
	{
		alert('File must be in zip format (*.zip)');
		return false;
	}
}

On your HTML form have you included return within the on-submit? I.E.

<form name="" action="" target="_self" onsubmit="return checkForm()">
<!--Form Stuff-->
</form>

=)

On your HTML form have you included return within the on-submit? I.E.

<form name="" action="" target="_self" onsubmit="return checkForm()">
<!--Form Stuff-->
</form>

=)

It's always the really simple things that seem to escape one's eyes o.O :P

P.S. For those that are unsure of what I was missing. It was the "return " in the onSubmit.