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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:47:17+00:00 2026-06-06T04:47:17+00:00

I am trying to test passwords. I need to do some testing on the

  • 0

I am trying to test passwords. I need to do some testing on the string. I am finding that my special characters evaluate to true when I test them with toUpperCase(). I would suspect that they would evaluate to false.

How should I test for special characters?

// CREATE ARRAY OF CHARACTERS
CharacterArray = ["1","2","3","a","b","c","D","E","F","/","+",")"];

// TEST CHARACTERS 
function testCharacters() {
    // GET ARRAY LEN
    var CharacterArrayLen = CharacterArray.length;
    // LOOP THROUGH ARRAY
    for (i = 0; i < CharacterArrayLen; i++) {
        // PARSE SINGLE CHARACTER
        var ThisChar = CharacterArray[i];

        if (!isNaN(ThisChar)) {
            alert(ThisChar + ' is numeric!');
        } else {
            if (ThisChar === ThisChar.toUpperCase()) {
                alert(ThisChar + ' is upper case');
            } else if (ThisChar === ThisChar.toLowerCase()) {
                alert(ThisChar + " is lower case");
            }
        }   
    }
}
testCharacters();
  • 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-06T04:47:18+00:00Added an answer on June 6, 2026 at 4:47 am

    They aren’t upper or lower case. Both toUpperCase and toLowerCase return the same thing for those characters. If you tested for lower case first, you’d find they’re all lower case!

    You can use some regex to see if the character is in the alphabet.

    ThisChar.match(/^[a-zA-Z]$/)
    

    will return null on non-alphabet characters.

    If you’re just trying to see if each of those characters is in your array, you can use indexOf

    CharacterArray.indexOf('a')
    > 3
    CharacterArray.indexOf('A')
    > -1
    

    The second one returns -1 because A is not in the array.

    Here’s a DEMO using regex.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to test an app that creates some custom permissions during intialization. These
I am new to unit testing and I am trying to test some of
I'm trying to create a Regex test in JavaScript that will test a string
I am trying to validate a password string with javascript and need some help
When trying to unit test some part of my code, I need a user
Trying to test that an event handler gets called on a clicked element with
I trying to test an AccountController that uses DotNetOpenAuth but I am running into
I'm trying to test some TPL dataflow code and run into what looks like
I want to test some features that needs delayed jobs to work, on cucumber.
I'm trying to test web service calls using an ASP.NET page that creates a

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.