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 7518269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:43:39+00:00 2026-05-30T01:43:39+00:00

I am trying to learn if there is a javascript method to search a

  • 0

I am trying to learn if there is a javascript method to search a string to see if that string contains any of the values in an array of strings.

An example would be:

var a = 'How now brown cow';
var b = new Array('red', 'green', 'brown');

The resulting function would return true because the word brown is contained within the string a .

More specifically what I am trying to do (except using values from form input) is:

var a = '12345@gmail.com';
var b = new Array('.com', '.net', '.org');

This should also return true. Then based on this I will go on to accept var a as valid.

My actual code as of right now (which always returns null) is as follows:

function check_domain(){
  for(var i=0; i<domains.length; i++){
    var d = domains[i];
    if(elemen.value.indexOf(d) != d){
      return null;
    }
    else{
      vEmail.style.visibility = 'visible';
    }
  }
}

  window.domains = new Array(....Array values 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-05-30T01:43:40+00:00Added an answer on May 30, 2026 at 1:43 am

    Not sure why you’ve got .indexOf(d) != d. Shouldn’t it be:

    function check_domain(){
       var d, i;
       for(i = 0; i < domains.length; i++){
          d = domains[i];
          if(elemen.value.indexOf(d) != -1) {
            return true;
          }
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently trying to learn Javascript and understand that functions are one of
I'm trying to learn Objective-C for xcode. I was wondering if there was an
Trying to learn MVP pattern with C#... Does anyone know of any particularly good
I have no experience with jquery or javascript for that matter. I am trying
I am trying to learn how to animate in javascript and I was just
In trying to learn JavaScript closures, I've confused myself a bit. From what I've
I am trying to learn and improve my javascript skills. A very helpful tool
Currently, I'm trying to learn Javascript by writing my code in Gedit then attempting
I'm currently trying to learn Knockout.JS - I'm also relatively new to JavaScript itself.
I'm trying to learn some html/css/javascript, so I'm writing myself a teaching project. The

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.