Okay, so here’s how you can easily create a simple JavaScript password generator with a little bit of styling.
The program will be divided into three parts:
the html part,
the CSS part
the JavaScript part
so I will give you the source code for the JavaScript password generator and also explain how it works.
Create basic HTML format
First, create a basic HTML document format with appropriate tags like title and title. Then open your code editor and type the following code.
<! DocType html>
<html> is the
<in the head>
<title> Page title </title>
<script src = “https://code.jquery.com/jquery-3.1.1.js”> </script>
</head> is the
<body> is
</body> is correct
</html> is the source
Now that you have created the basic HTML format, save the file as index.html.
Now create a container with buttons and input fields with the password displayed between the body tags.
<Div> is
<input type=”text” id=”input” read-only=””> <br>
<input type=”button” value=”generate” id=”gen” onclick=”gen()”> <br>
<input type=”button” value=”copy” id=”police”>
</div> is the source
After creating the containers and buttons you can add CSS.
Add CSS
As for styling our password generator, we will use some CSS. First we will style the body in navy blue and also add basic CSS styling.
*is.
Margin: 0%.
Recruitment:
font-family: monospace;
a
body {
Background color: dark blue
Minimum height: 100vh
a
Then now we will style the input fields.
Input :: option
background color: transparent;
a
Input: Focus
Temperament: None
a
enter {
Background Color: Transparent
Edge: Nothing;
a
enter {
Status: Relative
above:
left:
Conversion: Translate (-50%, -50%);
text alignment: center;
Margin: 10px
a
# input { .
Color: Grey
background color: white;
box shadow: 2px 2px 2px red, -2px -2px 2px black;
Font size: 1.5 cm
Width: Auto
a
#Ginny {
background color: pink;
Upholstery: 2px 5px
a
# police
background color: yellow;
Upholstery: 2px 5px
a
Div
Status: Absolutely;
Width: Auto
Height: Otto;
above:
left:
Conversion: Translate (-50%, -50%);
a
With the input fields in place, we can style the copy button, which is the cover tag.
Cover over the cover
Position: Fixed;
background color: yellow;
Width: 100%.
Height: 100%.
above:
left:
conversion: translate(-50%, -50%);
Performance: None
Transfer duration: 10ms
text alignment: center;
Font Weight: 700
Font size: 1.5 cm
a
Cover # active
Display: inline block;
a
The CSS styling is done, now we can get to the main part, which is JavaScript code that can be generated by clicking on a random password.
Add JavaScript
First I’ll give you the JavaScript code, then I’ll explain how it works.
var chars = “0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$&%*”;
V length = 16;
var pass = (” #input”).
var genb = (“#gen”);
var passw = “”.
var gen = (() =>
passw = “” .
for (drop j = 1 ; j <= length ; j++)
passw + = chars.charAt(Math.Random() * 70
a
pass.attr(“value”, passW);
});
copied = (() =>
$(“Cover”). toggle(” #active”);
});
var copy = $(” #police “). Click (() =>
pass.select();
document.execCommand(“Copy”);
$(“Cover”). html (“New password copied: <BR>” + passw);
Copy () .
set timeout(copied, 500);
});
general ()
So if you’re wondering how the above JavaScript code works, here’s how it works in simple terms.
var characters – This line contains all characters, symbols, and numbers for the generated password.
var length – Limits the length of the password generated by this line.
var pass & genb – These are input button triggers so clicking these html input buttons triggers javascript.
var gen – code that generates random passwords using var characters and displays them in the var passw field.
was Copy & Copy – This will display the Copy button, which copies the contents of the password field when clicked.
That is, this way you can easily create a random password generator using JavaScript.
check more : The Most Popular Languages Used in Game Development