【发布时间】:2026-01-14 00:55:02
【问题描述】:
请我想知道如何在注册页面中存储用户输入数据然后我将其传递给登录页面并在登录页面中验证用户是否写了正确的用户名和密码(已经从注册页面传递) 这是我注册页面的js代码:
<head>
<script>
//function to check if the passoword is matched
function checkpass() {
if (document.getElementById('psw').value ==
document.getElementById('psw-confirm').value) {
document.getElementById('message').style.color = 'green';
document.getElementById('message').innerHTML = 'Matched Passowrds';
} else {
document.getElementById('message').style.color = 'red';
document.getElementById('message').innerHTML = 'Those passwords didn’t match. Try again.';
}
}
//function to disable the submit button if the password is not matched
function check_pass() {
if (document.getElementById('psw').value ==
document.getElementById('psw-confirm').value) {
document.getElementById('submit').disabled = false;
} else {
document.getElementById('submit').disabled = true;
}
}
//function of cancel button
function goBack() {
window.history.back();
}
//function to only choose one gendre
function onlyOne(checkbox) {
var checkboxes = document.getElementsByName('check')
checkboxes.forEach((item) => {
if (item !== checkbox) item.checked = false
})
}
</script>
<link href="RegisterartinStyle.css" rel="stylesheet">
</head>
【问题讨论】:
-
您的问题中有 cookie 标签。您在使用 cookie 时遇到问题吗?你读过docs吗?
标签: javascript web cookies frontend setcookie