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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.