Untitled
unknown
plain_text
a year ago
1.5 kB
10
Indexable
// Registration Form Validation
document.getElementById('registrationForm').addEventListener('submit', function(event) {
const name = document.getElementById('name').value;
const email = document.getElementById('email').value;
const password = document.getElementById('password').value;
const confirmPassword = document.getElementById('confirmPassword').value;
// Check if fields are empty
if (!name || !email || !password || !confirmPassword) {
alert('All fields are required!');
event.preventDefault(); // Prevent form submission
return;
}
// Check if password and confirm password match
if (password !== confirmPassword) {
alert('Passwords do not match!');
event.preventDefault(); // Prevent form submission
return;
}
alert('Registration successful!');
});
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
header {
background-color: #333;
color: white;
padding: 10px;
text-align: center;
}
nav a {
margin: 0 15px;
color: white;
text-decoration: none;
}
footer {
background-color: #333;
color: white;
text-align: center;
padding: 10px 0;
position: fixed;
width: 100%;
bottom: 0;
}
form {
margin-top: 20px;
}
form input {
width: 100%;
padding: 10px;
margin: 10px 0;
}
button {
padding: 10px 20px;
background-color: #333;
color: white;
border: none;
cursor: pointer;
}Editor is loading...
Leave a Comment