☀️
Light
File Preview
Code_590703.cpp
const form = document.getElementById('registrationForm'); form.addEventListener('submit', function(event){ event.preventDefault(); alert("button clicked"); const firstName = document.getElementById('firstName').value; const lastName = document.getElementById('lastName').value; const email = document.getElementById('email').value; const password = document.getElementById('password').value; const confirmPassword = document.getElementById('confirmPassword').value; const namePattern = /^[A-Za-z]+$/; const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; if(namePattern.test(firstName) == false){ alert("Invalid First Name"); return; } if(namePattern.test(lastName) == false){ alert("Invalid Last Name"); return; } if(emailPattern.test(email) == false){ alert("Invalid Email"); return; } if(password.length < 6){ alert("Password must be 6 characters"); return; } if(password != confirmPassword){ alert("Password does not match"); return; } const gender = document.querySelector('input[name="gender"]:checked'); if(gender == null){ alert("Select Gender"); return; } const clubs = document.querySelectorAll('input[type="checkbox"]:checked'); if(clubs.length == 0){ alert("Select at least one club"); return; } const reason = document.getElementById('reason').value; if(reason.length < 20){ alert("Write at least 20 characters"); return; } alert("Registration Successful"); });
Copy text
Download
<< Back to Home