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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:26:50+00:00 2026-06-06T23:26:50+00:00

I am trying out this simple css and js password strength checker. It works

  • 0

I am trying out this simple css and js password strength checker. It works very nicely when the css and js is included in the file as below. If I put the js in a seperate file however and include it in this file it will not work. Also if I put the css in an external css file it wont style the page.

To include it I was simply putting:

<link rel="stylesheet" type="text/css" href="/css/style.css" />
<script type="text/javascript" src="/js/js.js"></script>

I dont see what Im doing wrong or is it to do with the code and it needs to be in the same file for some reason?

the file is a php file because I will later be adding php to it but that doesnt change anything does it?

<html>
<head>
    <title>strength check</title>
    <style type="text/css">
    #passwordStrength {
        height:10px;
        display:block;
        float:left; 
    }
    .strength0 {
        width:150px;
        background:#cccccc;
    }     
    .strength1 {
        width:20px;
        background:#ff0000;
    } 
    .strength2 {
        width:40px;    
        background:#ff5f5f;
    } 
    .strength3 { 
        width:60px;
        background:#56e500;
    }
    .strength4 {
        background:#4dcd00;
        width:80px;
    } 
    .strength5 { 
        background:#399800;
        width:150px;
    } 
    </style>
    <script language="javascript" type="text/javascript">
    function passwordStrength(password) {

        var desc = new Array();
        desc[0] = "Very Weak";
        desc[1] = "Weak";
        desc[2] = "Better";
        desc[3] = "Medium";
        desc[4] = "Strong";
        desc[5] = "Strongest";

        var score = 0;

        //if password bigger than 6 give 1 point
        if (password.length > 6) score++;

        //if password has both lower and uppercase characters give 1 point      
        if ((password.match(/[a-z]/)) && (password.match(/[A-Z]/))) score++;

        //if password has at least one number give 1 point
        if (password.match(/\d+/)) score++;

        //if password has at least one special caracther give 1 point
        if (password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/)) score++;
        //if password bigger than 12 give another 1 point
        if (password.length > 12) score++;

        document.getElementById("passwordDescription").innerHTML = desc[score];
        document.getElementById("passwordStrength").className = "strength" + score;
    }​
    </script>   
</head>
<body>
    <input type="password" caption="password" name="password" onkeyup="passwordStrength(this.value);" size="60">
    <div style="font-size: 10px"; id="passwordDescription">Password Strength</div>
    <div class="strength0" id="passwordStrength"></div> 
</body>
</html>
  • 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-06T23:26:52+00:00Added an answer on June 6, 2026 at 11:26 pm

    Remove the / at the begining of your links :

    <link rel="stylesheet" type="text/css" href="css/style.css" />
    <script type="text/javascript" src="js/js.js"></script>
    

    Those / mean your files are at the root of your domain.

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

Sidebar

Related Questions

this may be stupidly simple but I'm trying to figure out a way to
I am having the hardest time trying to figure out this (should be) simple
This one has me pulling my hair out. I'm trying to implement a very
I'm trying to build a very simple pure css navigation bar, but have hit
Boost Network I am trying out this code in a small console app on
So I'm trying out this new TDD thing (about time haha). Anyways I have
I am learning LINQ and was trying out this example related to select clause.
Hi iam new to c++ and iam trying out this vector program and i
Trying to figure out this pseudo code. The following is assumed.... I can only
I'm trying to figure out this weird issue I've been having, and the root

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.