как вариант:
let login = document.getElementById("login");
let password = document.getElementById("password");
let email = document.getElementById("email");
const vLogin = /^[a-zA-Z]{4,16}$/;
const vEmail = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
const vPassword = /^[a-zA-Z0-9]{8,15}$/;
let button = document.getElementById("button");
let usersArray = [];
function addUser(array) {
vLogin.test(login.value);
vEmail.test(email.value);
vPassword.test(password.value);
const user = {
login: login.value,
email: password.value,
password: email.value,
}
array.push(user)
login.value = '';
email.value = '';
password.value = '';
}
function saveUsers() {
addUser(usersArray)
console.log(usersArray)
}
button.addEventListener('click', saveUsers)