<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<h1>Регистрация</h1>
<p>
Введите логин:<br>
<input type="text" id="login">
<br>
Введите пароль<br>
<input type="password">
<br>
<input type="submit">
</p>
</body>
</html>
{
"login":"",
"password":""
}
<input type="text" id="login">
<script>
var input = document.getElementById("login")
var data = {
"login":"",
"password":""
}
input.oninput = function() {
data.login = input.value;
};
</script>
<form onsubmit="func()">
<h1>Регистрация</h1>
<p>
Введите логин:<br>
<input type="text" id="login">
<br>
Введите пароль<br>
<input type="password" id="password">
<br>
<input type="submit">
</p>
</form>
<script>
const func = e => {
console.log({
"login": document.getElementById('login').value,
"password": document.getElementById('password').value,
})
}
</script>