|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > File Upload |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|