Untitled
unknown
plain_text
a year ago
1.1 kB
8
Indexable
document.getElementById('registrationForm').addEventListener('submit', function(event) {
event.preventDefault(); // Prevent the form from submitting immediately
// Retrieve values from the form fields
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 any fields are empty
if (!name || !email || !password || !confirmPassword) {
alert('All fields are required!');
return; // Exit the function to prevent further validation
}
// Check if password and confirm password match
if (password !== confirmPassword) {
alert('Passwords do not match!');
return; // Exit the function to prevent further validation
}
// If all checks pass, you can proceed with form submission or further processing
// For example, you might want to submit the form here or send the data via AJAX
});Editor is loading...
Leave a Comment