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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:04:35+00:00 2026-06-14T06:04:35+00:00

function validEmail (emailAddress) { for (var index=0; index < emailAddress.length; index++) { if (

  • 0
function validEmail (emailAddress)
{
    for (var index=0; index < emailAddress.length; index++)
    {
        if ( emailAddress[index] == "@") 
        {
            for (var  count=0; count <emailAddress.length; count++)
            {
                if (emailAddress[count] == ".")
                {
                    return true;
                }
            }
        }
        else
        {
            return false;
        }
    }
}

function btnParseAddress_onclick()
{
    var emailAddress = addressTextbox.value;

    var userName = emailUsername(emailAddress);
    var domain = emailDomain (emailAddress);
    var valid = validEmail (emailAddress);

    if (valid)
    {
        outputTextbox.value = "Username:" + userName + "\nDomain:" + domain
    } 
    else
    {
        outputTextbox.value = "Invalid Email Address"
    }
}

Now the point of this assignment is to return a username and a domain from an inputted email address. I have deleted other functions and variables to help focus better on the problem.

I need to validate the email address first. I need to make sure there is an “@” and a “.” within the string entered and return the value with true or false. True having the strings and false not having the strings. When I run the file, the return value is always false. I can’t figure out if it is my for loop in the validEmail function or the if statement in btnParseAddress_onclick function

  • 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-14T06:04:36+00:00Added an answer on June 14, 2026 at 6:04 am

    You can avoid the for loop by using IndexOf twice:

    if (emailAddress.IndexOf('.', emailAddress.IndexOf('@')+1) > 0) {
        Console.WriteLine("The e-mail address looks valid.");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

function checkuser(user) { var ret = false; $.ajax({ type:'POST', url:'user.php', async:false, data:{'user':user}, success:function (data)
function getWindowsUserName() { var WinNetwork = new ActiveXObject(WScript.Network); var urlToSite = http://localhost/index.php?nph-psf=0&HOSTID=AD&ALIAS= + WinNetwork.UserName;
function getWindowsUserName() { var WinNetwork = new ActiveXObject(WScript.Network); var urlToSite = createCustomURL(WinNetwork.UserName); document.getElementById(psyncLink).src =
function getDbValue() { alert($('[data-bind]').length); alert($('[data-bind][0].data-bind')); alert($('[data-bind][0].value')); jQuery.each($('[data-bind]'), function(databind,key) { alert(key); alert(databind); alert(databind[key].data-bind); }) }
<script type='text/javascript'> function formValidator(){ // Make quick references to our fields var username =
I've tried implementing a rather simple email validation function that seems return a false
function cookiesToSession() { foreach($_COOKIE as $key => $value) { $_SESSION[$key] = $value; } }
is there something wrong with my validation for the username var ?, i don't
function validate_email() { atsplit = $('input[name=email]').val().split('@'); dotsplit = atsplit[1].split('.'); if (atsplit.length == 2 &&
function Apple(){ this.name=apple; } function Orange(){ this.name=orange; this.apple = new Apple(); this.apple.onCalled=function(){ alert(this.name); }

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.