Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8658185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:42:10+00:00 2026-06-12T15:42:10+00:00

I have the following HTML: <input id=upload1 type=file /><br/> <input id=upload2 type=file /><br/> <input

  • 0

I have the following HTML:

<input id="upload1" type="file" /><br/>
<input id="upload2" type="file" /><br/>
<input id="upload3" type="file" /><br/>
<input id="upload4" type="file" /><br/>
<input id="upload5" type="file" /><br/>
<span id="label" style="color:red; display:none">
Wrong filetype!
</span>

And the following jQuery:

$('input:file').change(function(){
    var ext = $(this).val().split('.').pop().toLowerCase();
    $('#label').toggle(ext != 'pdf');
});

What I want to do, is only toggle the #label if all 5 of the input:file elements pass the validation (pdf extension only). Or no file selected.

At the moment, if i select a .jpg first, the #label displays, then if i select a .pdf the #label disappears. This is incorrect as there is still a .jpg selected in one of the five input:file elements.

EDIT: Fiddle here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T15:42:11+00:00Added an answer on June 12, 2026 at 3:42 pm

    You would need to change it to:

    $('input:file').change(function(){
        var
            all_ok = true,
            inputs_set = $('input:file');
    
        for (var e in inputs_set) {
            if (e.val().split('.').pop().toLowerCase() != 'pdf') {
                all_ok = false;
            }
        }
    
        $('#label').toggle(!all_ok);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: HTML <label>File Upload: </label> <input type=file name=file[] /> jQuery
I have the following bit of HTML: <label>First Name</label><input name=Question62 type=text value= /> Unfortunately
In an HTML file I have the following: <input type=... name=myInput1 /> In a
I have the following html code to upload an image: <input type=file name=before size=40>
I have the following HTMl: <input id=brandID name=brandID type=hidden value= /> <select id=selectList class=textfield70pc
I have the following HTML: <input type=email id=email> I want to type text into
I have the following HTML on my web page: <input id=htmlEdit type=checkbox/> Once the
I have the following HTML: <tr> <td> <input type=checkbox class=showFilter /> Ranks </td> </tr>
I have the following html code: <form> <table> <tbody> <tr> <td> <span>Quantity<span class=pull-right>3</span> <input
Suppose I have the following HTML: <form id=myform> <input type='checkbox' name='foo[]'/> Check 1<br/> <input

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.