Untitled
unknown
plain_text
7 days ago
1.6 kB
3
Indexable
Never
// Simple carousel control logic let currentSlide = 0; function showSlide(index) { const slides = document.querySelectorAll('.slide'); slides.forEach(slide => { slide.style.transform = `translateX(${index * -100}%)`; }); } function nextSlide() { const slides = document.querySelectorAll('.slide'); currentSlide = (currentSlide + 1) % slides.length; showSlide(currentSlide); } function prevSlide() { const slides = document.querySelectorAll('.slide'); currentSlide = (currentSlide - 1 + slides.length) % slides.length; showSlide(currentSlide); } // Custom validation for registration form document.getElementById('registrationForm').addEventListener('submit', function (e) { e.preventDefault(); const username = document.getElementById('username').value; const email = document.getElementById('email').value; const password = document.getElementById('password').value; const errorMessage = document.getElementById('error-message'); const usernameRegex = /^[A-Za-z0-9]{3,}$/; if (!usernameRegex.test(username)) { errorMessage.textContent = "Username must be at least 3 characters long and alphanumeric."; return; } if (!email.includes('@')) { errorMessage.textContent = "Please enter a valid email address."; return; } if (password.length < 6) { errorMessage.textContent = "Password must be at least 6 characters long."; return; } errorMessage.textContent = "Registration successful!"; alert("Form submitted successfully!"); document.getElementById('registrationForm').reset(); });
Leave a Comment