let number2 = document.querySelector('.numder2').value;
<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>
word-wrap: break-word;