Jump to content

validating multiple file input elements


horseatingweeds

Recommended Posts

I'm writing a script to check several form elements, several of them are file inputs. I've found that only the first file element with contents will be checked, the rest are ignored as is the script written to check them. Is this something inherent in file fields?

 

Here's the page if you want to take a look:

http://www.gentledoberman.com/test-input.php

 

Do I need to put each file input in a separate form perhaps?

Link to comment
https://forums.phpfreaks.com/topic/60890-validating-multiple-file-input-elements/
Share on other sites

In your input_formCheck.js:

// ... 
}else if (form.fileImg1.value.length > 0){
  alert('');
}else{
  returnValue = true;
}

 

Perhaps if you actually checked the values of form.fileImg2.value.length and form.fileImg3.value.length you could validate them.

 

Also, I noticed you're looking at file extensions to determine MIME type; that's considered bad practice.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.