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

  • Home
  • SEARCH
  • 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 8335037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:32:34+00:00 2026-06-09T03:32:34+00:00

I have a form in which people can enter file paths. I want to

  • 0

I have a form in which people can enter file paths. I want to make sure that the paths they are entering point to pictures so here is what I thought would work.

function checkExt()
{
    var extension= /* I know that the code to cut the extension off of the file
                      is working correctly so for now let's just go with it ok */
    if(extension!="jpg" || "gif" || "bmp" || "png" || "whatever else")
        alert("The file extension you have entered is not supported");
}

But this does not work. I have tracked it down to the if statement because if I select only 1 kind of file to check for, then it will work correctly. So my question to you is what the hell do I have to change to make this thing work correctly. I’ve been on this for about three hours now and it’s driving me mad. Thanks for all of the help in advance.

  • 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-09T03:32:37+00:00Added an answer on June 9, 2026 at 3:32 am

    That’s a syntax and a logic error. It should be:

    if (extension != "jpg" && 
        extension != "gif" && 
        extension != "bmp" && 
        extension != "png" && 
        extension != "whatever else") {
        // This will execute when the extension is NOT one of the expected 
        // extensions.
    }
    

    Furthermore, you could handle it a little more succinctly with a regular expression:

    if (!/jpg|gif|bmp|png|whatever/.test(extension)) {
        // This will execute when the extension is NOT one of the expected 
        // extensions.
    }
    

    Addendum:

    The examples above execute the body of the if-statement when the value of extension is not one of the supported values. If you wanted to execute the body of the if-statement when the value of extensions is one of the supported values, you would change the logic from not equal/and to equal/or, like so:

    if (extension == "jpg" || 
        extension == "gif" || 
        extension == "bmp" || 
        extension == "png" || 
        extension == "whatever else") {
        // This will execute when the extension is one of the expected extensions.
    }
    

    And again, it’d be more concise using a regular expression:

    // I just removed the leading ! from the test case.
    if (/jpg|gif|bmp|png|whatever/.test(extension)) {
        // This will execute when the extension is one of the expected extensions.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a form where people can enter a code, for example H23J3PW, which
I have a website that people can book courses and workshops on. They can
I have a form in which people will be entering dollar values. Possible inputs:
I have a form view which people use to update a record in the
I have a form which I want to be 'resusable' for a variety of
i have an form which will send some data to an php file ,
I have a form in which people shall be able to add the same
I am trying to auto increment my xml file. I have a form that
So as it stands I have a form that hands a file to my
I have a TMemo on a form which allows users to enter a list

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.