Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Still submitting form after alert 1

Status
Not open for further replies.

snowboardr

Programmer
Joined
Feb 22, 2002
Messages
1,401
Location
PH
I can't get this code to stop the submit if the error occurs, do you see whats wrong? I have it the function run on onSubmit="CheckTheFile();" and it is showing the error message

Jason


Code:
function CheckTheFile() {
	if(document.frmSend.attach1.value=="") {
		alert("Please click browse and find the ad you would like to upload.");
		return false;
	} else {
		if((document.frmSend.attach1.value.lastIndexOf(".jpg")==-1) || (document.frmSend.attach1.value.lastIndexOf(".gif")==-1) || (document.frmSend.attach1.value.lastIndexOf(".tif")==-1) || (document.frmSend.attach1.value.lastIndexOf(".png")==-1)) {
			alert("File types accepted : jpg, gif, png, or tif");
			document.frmSend.attach1.value="";
			return false;
		} else {		
			return true;
			document.frmSend.submit();
		}	
	}
}

Army : Combat Engineer : 21B

 
>onSubmit="CheckTheFile();"
[tt]onSubmit="[red]return[/red] CheckTheFile();" [/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top