JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old June 30th, 2004, 02:53 AM
pjfuerte pjfuerte is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 1 pjfuerte User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
File Upload

Hi,

I have a form which includes a textbox and a file upload.

<form name="form1" method="post" enctype="multipart/form-data" action="control.php" onSubmit="return validateForm()">
<input name="name" type="text">
<input name="userfile" type="file">
</form>

function validateForm()
{
var form = document.forms["form1"]
var myname = form.name.value
var filename = form.userfile.value
if(myname=="" || myname==null || filename=="" || filename==null)
{
alert("Error: Please fill in all information")
return false
}
return true
}

The problem is when the file has a value (user selected a filename) but the text box empty, it doesnt go through with the validation/validateForm() function.
But if it is the other way around, if the textbox has a value but the file hasn't, it goes through validation and show the alert box.

I need help with this. Thanks

Reply With Quote
  #2  
Old July 2nd, 2004, 06:41 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 11 sec
Reputation Power: 8
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Try using a different name for your form controls, as "name" is a reserved word. Try something like: "filename_title". I did this and it worked.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > File Upload


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway