//let username = document.getElementById('username');
//let email = document.getElementById('email');
//let password = document.getElementById('password');
//let password2 = document.getElementById('password2');
function check(arr) {
arr.forEach((input) => {
console.log(input);
})
}
// Addeventlisteners
document.getElementById('submit').addEventListener('click', (e) => {
e.preventDefault();
check([username, email, password, password2]);
})
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Form Validation</title>
</head>
<body>
<div class="container">
<h1>Register with us</h1>
<form action="">
<div class="row">
<label for="">Username</label>
<input id="username" type="text" placeholder="Enter username">
<small>Error message</small>
</div>
<div class="row">
<label for="">Email</label>
<input id="email" type="text" placeholder="Enter email">
<small>Error message</small>
</div>
<div class="row">
<label for="">Password</label>
<input id="password" type="password" placeholder="Enter password">
<small>Error message</small>
</div>
<div class="row">
<label for="">Confirm Password</label>
<input type="password" id="password2" placeholder="Enter password again">
<small>Error message</small>
</div>
<button id="submit">Submit</button>
</form>
</div>
<script src="app.js">
</script>
</body></html>
output when i clicked the submit button
**我什至清除了我的缓存,但随后显示了输入标签。有人可以帮我吗,我找不到解决方案。这是我第一次在这里问问题,所以我真的不知道如何发布问题**
Looks like the
app.js
file has defined the four values (username
,email
,password
,password2
). Could you please check the file?