Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Asp and Jscript validation help...
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

weeweeslap
Senior Member

USA
1077 Posts

Posted - 04 September 2007 :  22:26:15  Show Profile  Visit weeweeslap's Homepage  Send weeweeslap an AOL message  Send weeweeslap a Yahoo! Message
Hi guys and gals. I grabbed 2 scripts off the internet and merged them to hopefully have file extension validation. While the alert goes off saying that I can only upload jpg files it still continues with the upload rather than just quitting. I was wondering if you guys could take a look at this code and lend a hand with it. I want it so that only .jpg files can be uploaded. The validation works, but after clicking ok on the alert box, the upload continues on and well uploads the file no matter what file extension it is. I'd appreciate your help, here's the link to the file:
http://www.weeweeslap.com/scrapbook/up.txt
thanks!
if the link appears to have been processed, simply view source and the asp code is displayed, not sure why windows 2003 or why windows vista does that to me. Thanks!

coaster crazy

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 05 September 2007 :  04:10:42  Show Profile  Visit HuwR's Homepage
instead of using a submit button, just use a button, and then do a formObj.submit() in your checkExt function
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 05 September 2007 :  05:34:31  Show Profile
Or, remove the onclick event from your submit input as well as the second onsubmit from your opening form tag and then call checkExt from checkForm like so:
function checkForm(){
 if(document.form1.fileUpload.value.length>2){
  if(checkExt(document.form1)){
   return true
  }else{
   alert("You can only upload jpg images.")
   return false
  }
 }else{
  alert("Please select an image file to upload.")
  return false
 }
}
Finally, you can delete the alert and focus from the checkExt function. You can add the focus back in above, if you want; I just left it out.


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”

Edited by - Shaggy on 05 September 2007 11:22:01
Go to Top of Page

weeweeslap
Senior Member

USA
1077 Posts

Posted - 05 September 2007 :  10:20:31  Show Profile  Visit weeweeslap's Homepage  Send weeweeslap an AOL message  Send weeweeslap a Yahoo! Message
Cool, thanks guys! All up and running now

-edit-
now even if I do send a proper file it wont process the upload lol Maybe I need to find some better code

coaster crazy

Edited by - weeweeslap on 05 September 2007 10:27:45
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 05 September 2007 :  11:22:23  Show Profile
Wee error in the code I posted; fixed above.


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

weeweeslap
Senior Member

USA
1077 Posts

Posted - 05 September 2007 :  11:34:11  Show Profile  Visit weeweeslap's Homepage  Send weeweeslap an AOL message  Send weeweeslap a Yahoo! Message
I updated it with your updated code and same thing, it continues on with the upload even if it's the invalid file extension and this time I don't get the alert. Here's the updated txt file:
http://www.weeweeslap.com/scrapbook/up.txt
live test page:
http://www.weeweeslap.com/scrapbook/up.asp

coaster crazy

Edited by - weeweeslap on 05 September 2007 11:34:46
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 05 September 2007 :  12:16:08  Show Profile
You replaced your checkExt function with my checkForm function.


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

weeweeslap
Senior Member

USA
1077 Posts

Posted - 05 September 2007 :  16:11:05  Show Profile  Visit weeweeslap's Homepage  Send weeweeslap an AOL message  Send weeweeslap a Yahoo! Message
oops, ok I fixed what I broke and did it the way yo mentioned above, now when I input an invalid file type it alerts me twice once on clicking submit and once after clicking ok on the first alert box, that I can only use .jpg files but after clicking ok on the second alert box it yet again proceeds with the upload.
Here's the updated txt file:
http://www.weeweeslap.com/scrapbook/up.txt
live test page:
http://www.weeweeslap.com/scrapbook/up.asp

Sorry if I am not understanding what you're telling me to change, I still consider myself a newbie to coding even after years of having to deal with it
Forgot to mention that if I do use a valid .jpg file it gives me the alert message once and then proceeds with the upload after clicking ok.

coaster crazy

Edited by - weeweeslap on 05 September 2007 17:31:54
Go to Top of Page

weeweeslap
Senior Member

USA
1077 Posts

Posted - 05 September 2007 :  18:47:53  Show Profile  Visit weeweeslap's Homepage  Send weeweeslap an AOL message  Send weeweeslap a Yahoo! Message
I ditched the whole javascript and did it through an asp way which requires the file to be uploaded but if it is found tonot be of the right file extension, it is deleted immediately.

coaster crazy
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.91 seconds. Powered By: Snitz Forums 2000 Version 3.4.07