#javascript #html #css
#javascript #HTML #css
Вопрос:
Я новичок в мире JS, и для своей практики пытаюсь создать простое поле ввода, в котором пользователи могут переключать (показывать / скрывать) свой пароль.
Пока я добавляю все (иконки и css), но я не знаю, почему у меня эта ошибка в моем JS-коде, просто запустите код, и вы увидите.
Кроме того, мои значки каким-то образом перепутались, я не знаю, как это исправить.
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Title</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
html,
body {
height: 100%;
}
* {
margin: 0;
padding: 0;
text-decoration: none;
font-family: 'Roboto', sans-serif;
box-sizing: border-box
}
body {
background-color: #f9fbff
}
.source-image {
width: 100%;
background-repeat: no-repeat;
background-size: auto;
position: fixed;
max-width: 100%;
display: block
}
#login-form {
width: 460px;
background: 0 0;
padding: 80px 40px;
position: absolute;
left: 50%;
top: 40%;
transform: translate(-50%, -50%);
margin: 20px 0
}
.input_img {
position: absolute;
bottom: 20px;
left: 13px;
height: 30px
}
#login-form h1 {
text-align: center;
margin-bottom: 60px;
color: #191c3c;
font-size: 30px
}
.logoHolder>img {
width: 60%;
margin-bottom: 12px;
margin-left: auto;
margin-right: auto;
display: block
}
#login-form p {
font-size: 16px;
color: #333
}
#login-form p a {
color: #191c3c;
text-decoration: underline;
font-weight: 700;
}
#login-form p {
font-size: 16px;
color: #333
}
#login-form .entryText {
font-size: 15px;
text-align: center;
}
#login-form p a:focus {
border: 1px solid #515772
}
#login-form label {
color: #4a4d67;
font-weight: 700;
margin-bottom: 10px !important
}
.input-box {
position: relative;
margin: 30px 0
}
.input-box input {
font-size: 15px;
color: #333;
border: 1px solid #51577245;
width: 100%;
line-height: 1.2;
font-size: 18px;
outline: 0;
background: #fff;
padding: 0 5px;
height: 72px;
border-radius: 5px;
padding-left: 57px;
box-shadow: 0 3px 11px 0 rgba(81, 87, 114, .2);
margin-top: 15px
}
.input-box input:focus {
border: 1px solid #515772
}
.input-box span::before {
content: attr(data-placeholder);
position: absolute;
top: 50%;
left: 5px;
color: #515772;
transform: translateY(-50%);
z-index: -1;
transition: .5s;
padding-left: 20px
}
.validation {
border-color: #c00000 !important;
margin-bottom: 7px;
}
.feedback {
color: #c00000;
}
.error {
color: #c00000;
font-weight: bold;
text-align: center;
margin: 30px 0;
}
::placeholder {
margin-left: 60px;
color: #8b8d9d;
font-size: 14px;
font-weight: 700;
}
.cursor {
width: 17px
}
.input-box span::after {
content: '';
position: absolute;
width: 0;
height: 2px;
background: linear-gradient(120deg, #2196F3, #FF5722);
transition: .5s
}
.focus span::before {
top: -5px
}
.focus span::after {
width: 100%
}
.login-btn {
display: block;
width: 100%;
height: 62px;
border: none;
background: #515772;
background-size: 200%;
color: #fff;
outline: 0;
cursor: pointer;
margin: 20px 0 0;
border-radius: 8px;
transition: .5s;
font-size: 18px;
letter-spacing: 1px;
font-weight: 700
}
.login-btn:focus {
border: 2px solid #000
}
.login-btn:hover {
background-color: #2d3142
}
.bottom-links {
margin-top: 30px;
text-align: center;
font-size: 13px
}
.versionText {
background: transparent;
position: fixed;
inline-size: -webkit-fill-available;
bottom: 10px;
z-index: 10;
text-align: right;
font-size: 13px;
margin-right: 20px;
}
.bottom-links>p>a {
text-decoration: underline;
}
.bottom-links>p {
margin-bottom: 30px;
}
@media (max-width:768px) {
#login-form {
top: 45%;
padding: 0;
}
.source-image {
display: none
}
.versionText {
right: 0% !important;
align-items: center;
text-align: center;
}
}
@media (max-width:576px) {
#login-form {
width: 90%;
top: 50%;
padding: 0;
}
.source-image {
display: none
}
.versionText {
right: 0% !important;
align-items: center;
text-align: center;
}
}
@media (max-width:320px) {
#login-form {
width: 90%;
top: 50%;
padding: 0;
}
.source-image {
display: none
}
.versionText {
right: 0% !important;
align-items: center;
text-align: center;
}
}
@media (max-width:1440px) and (min-width:1024px) {
#login-form {
top: 45%;
padding: 0;
}
.versionText {
right: 0% !important;
align-items: center;
text-align: center;
}
}
@media (max-width:1440px) {
.source-image {
display: none
}
}
.version {
font-size: 13px;
margin-top: 10px;
}
.wrapper {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
width: 100%;
}
.field-icon {
float: right;
margin-left: -25px;
margin-top: -25px;
position: relative;
z-index: 2;
}
#password {
background-image: url("https://img.icons8.com/material-sharp/20/000000/visible.png");
background-position: 97% center;
background-repeat: no-repeat;
}
#password.visible {
background-image: url("https://img.icons8.com/material-outlined/20/000000/invisible.png");
}
#toggle-password {
display: none;
}
#toggle-password label {
text-indent: -9999px;
display: inline-block;
width: 20px;
height: 20px;
margin-left: -32px;
cursor: pointer !important;
}
</style>
<script>
const password = document.getElementById("password");
const togglePassword = document.getElementById("toggle-password");
togglePassword.addEventListener("click", toggleClicked);
function toggleClicked() {
password.classList.toggle("visible");
if (this.checked) {
password.type = "text";
} else {
password.type = "password";
}
}
</script>
</head>
<body onload="sf();">
<div class="wrapper">
<main>
<form id="login-form" method="post" name="f">
<div class="input-box">
<label for="password">Pass </label>
<input id="password" name="password" type="password" tabindex="2">
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAMAAADDpiTIAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAC91BMVEUAAABRUWtTWHFSWHRRV3JRWHNRV3JRWHNSV3JRV3FRWHJRV3NRV3JRV3JSV3JRV3JRVnFSV3JSWHNTVnJQVXOAgIBOVXFQVnNRVnJRVnJRV3JRV3JRV3FRV3FQV3NRV3FVVXdRVXNQWHNRV3JRV3JRV3JRV3JQV3FRWHJPVnFRXXRRV3RSV3JRV3JRV3JTWXFAQIBQVnFQV3JRV3JRVnFSWHNSVnBRV3JRV3JSW3ZRV3FRV3NRV3JQV3JSWHJPWHIAAABSWHJRVnFSV3JRV3JRV3FRV3JSVnFVVW1TVnFRV3JRV3JVVVVOWW9QVnJRV3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HKBhUVfp036prDl42/K8wMUKDhY1tGK /8UmP3o5Vs 2nDO9nx6mC6Rv/2cDR9tuXxRlXE9/w/IHHW2TSlagwAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMC0wNy0wM1QxMzoxNzowNSswMDowMD7FP 0AAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjAtMDctMDNUMTM6MTc6MDUrMDA6MDBPmIdRAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm 48GgAAAABJRU5ErkJggg=="
class="input_img" alt="">
<input type="checkbox" id="toggle-password" />
<label for="toggle-password">Show Password</label>
</div>
<button type="submit" class="login-btn" tabindex="3" name="Submit">Login</button>
</form>
</main>
</div>
</body>
</html>
Кто-нибудь может мне помочь с этим?
Комментарии:
1. Поместите свой скрипт в конец вашего HTML-файла, перед закрывающим
</body>
тегом. Ваш HTML анализируется сверху вниз. Поэтому, когда он достигает вашего JavaScript, форма еще не существует, и, таким образом, выбор элементов из нее приведет кnull
значениям.null
обычно является показателем того, что не найден или не существует при выборе элементов.2. вы вызываете метод, который вы еще не создали:
<body onload="sf();">
3. @EmielZuurbier, отлично, ошибка исчезла, но я не могу нажать на значок и показать пароль.
Ответ №1:
Вы пытаетесь выполнить функцию sf, которая не определена. Я не вижу этой функции в вашем коде. Вы пытаетесь найти переключатель-пароль до того, как он отобразится на странице. Удалите onload из body и добавьте свои скрипты в конце тега body.
Для быстрого исправления метки переключения добавьте это в свой стиль #toggle-password label, но я думаю, что идея с использованием этой метки плохая:
#toggle-password label {
{
position: absolute;
top: 50%;
right: 20px;
transform: translateY(-50%);
}
Вы также должны улучшить стиль замка, используя это:
.input_img {
position: absolute;
top: 50%;
left: 13px;
height: 30px;
transform: translateY(-50%);
}
Я меняю нижнюю часть с верхней на 50% и добавляю translate transfrom в положение calc из центра значка