Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

Question
100%

Please, I need help with this assignment, please. I pasted the HTML file and JavaScript file at the bottom of the instruction. Thank you so much.

Murach's JavaScript and jQuery 4th edition by MARY DELAMATER (Chapter 12)

Develop a password generator
In this exercise, you’ll develop an application that generates strong passwords of the length entered by the user.

1. In the JavaScript file, note the getRandomNumber() function. Also, note that the ready event handler contains the handler for the click event of the Get Password button and the handler for the click event of the Clear button.
The handler for the Get Password button clears the password text box and has a
constant named chars that contains some characters. The handler for the Clear button resets the text boxes and moves the focus to the first text box.
2. In the handler for the Get Password button, get the value entered by the user and make sure it’s a number. If it isn’t, display an alert dialog box with this message: “Please enter a valid number”.
3. If the number entered by the user is valid, code a for loop that iterates that number of times.
In each iteration of the loop, randomly select one of the characters from the chars constant and concatenate it to the password variable.
4. When the loop is finished, display the password in the password textbox.

JAVASCRIPT FILE

"use strict";

 

const getRandomNumber = max => {

    let random = null;

    if (!isNaN(max)) {

        random = Math.random();             // value >= 0.0 and < 1.0

        random = Math.floor(random * max);  // value is an integer between 0 and max - 1

        random = random + 1;                // value is an integer between 1 and max

    }

    return random;

};

 

$(document).ready( () => {

    $("#generate").click( () => {

 

        $("#password").val( "" ); // clear previous entry

        const chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-+!@";

       

         

    }); // end click()

   

    $("#clear").click( () => {

        $("#num").val( "" );

        $("#password").val( "" );

        $("#num").focus();

    }); // end click()

   

    // set focus on initial load

    $("#num").focus();

}); // end ready()

 

 

HTML FILE

<!DOCTYPE html>

<html>

<head>

    <meta charset="UTF-8">  

    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Password Generator</title>

    <link rel="stylesheet" href="password.css">

</head>

<body>

    <main>

        <h1>Generate a strong password</h1>

        <div>

            <label for="num">Number of characters:</label>

            <input type="text" id="num">

        </div>

        <div>

            <label for="password">Password:</label>

            <input type="text" id="password" disabled>

        </div>

        <div>

            <label></label>

            <input type="button" id="generate" value="Get Password">

            <input type="button" id="clear" value="Clear">

        </div>

    </main>

    <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"></script>

    <script src="password.js"></script>

</body>

</html>

 

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education