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 Password Generator Generate a strong password Number of characters: Password:
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>
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images