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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:14:57+00:00 2026-06-10T04:14:57+00:00

I have these two functions: validateEmail: function(value) { var regex = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; return (regex.test(value))

  • 0

I have these two functions:

validateEmail: function(value) {
    var regex = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
return (regex.test(value)) ? true : false;
}

validateEmails: function(string) {

    var self = shareEmail;
    var result = string.replace(/\s/g, "").split(/,|;/);

        for(var i = 0;i < result.length;i++) {
            if(!self.validateEmail(result[i])) {
                return false;
            } else {               
            return true;
        }
    }
}

The problem is that when I test the email like this if(!self.validateEmails(multipleEmails)) { i get true or false based only on the first email in the string, but I want to test for any email in the string.

Thank you!

  • 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-10T04:14:58+00:00Added an answer on June 10, 2026 at 4:14 am

    The problem is your if/else block; You are returning under both conditions. Which means that it leaves the function after evaluating only one element.

    I’ve modified validateEmails to demonstrate what you probably want to do:

    validateEmail: function(value) {
        var regex = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
        return (regex.test(value)) ? true : false;
    }
    
    validateEmails: function(string) {
        var self = shareEmail;
        var result = string.replace(/\s/g, "").split(/,|;/);
    
        for(var i = 0;i < result.length;i++) {
            if(!self.validateEmail(result[i])) {
                return false;
            }
        }
    
        return true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have these two functions: var $mainEdit= $(#main-edit); function getSelText() { var txt =
Let's say I have these two functions: function z(a,b,c){ $(#d).click(function(){ var sum = a+b+c;
Let's say I have these two functions: $(.a).animate( {left:100%}, {duration:10000, complete:function(){ //Something is triggered!!
How can I combine these two functions into one recursive function to have this
I have these two functions: jQuery.fn.enterText = function(e){ if( $(#cursor).val() && e.keyCode != 32
So I have these two functions, public static string[] CharToHex(string str, string prefix, string
Let's say I have these two functions: function fnChanger(fn) { fn = function() {
Assume that I have these two overloaded functions. public static void Main(string[]args) { int
I have these two functions: def comparison(a, b): return [-1, 0, 1].index(cmp(b, a)) def
I have these two functions (with Point2D & LineVector (has 2 Point2D member variables)

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.