JS ANSWER
JS ANSWER
<form id="registrationForm">
<label>Name: <input type="text" id="name"></label>
<span class="error" id="nameError"></span><br>
<button type="submit">Register</button>
</form>
<script>
document.getElementById("registrationForm").addEventListener("submit", function(event)
{
let isValid = true;
</body>
</html>
<div class="gallery">
<img src="image1.jpg" onclick="openModal(0)">
<img src="image2.jpg" onclick="openModal(1)">
<img src="image3.jpg" onclick="openModal(2)">
</div>
<script>
let images = ["image1.jpg", "image2.jpg", "image3.jpg"];
let currentIndex = 0;
function openModal(index) {
document.getElementById("modal").style.display = "block";
document.getElementById("modalImg").src = images[index];
currentIndex = index;
}
function closeModal() {
document.getElementById("modal").style.display = "none";
}
function prevImage() {
currentIndex = (currentIndex > 0) ? currentIndex - 1 : images.length - 1;
document.getElementById("modalImg").src = images[currentIndex];
}
function nextImage() {
currentIndex = (currentIndex < images.length - 1) ? currentIndex + 1 : 0;
document.getElementById("modalImg").src = images[currentIndex];
}
</script>
</body>
</html>
<h2>Quiz</h2>
<form id="quizForm">
<p>1. What is the capital of France?</p>
<input type="radio" name="q1" value="Paris"> Paris<br>
<input type="radio" name="q1" value="London"> London<br>
<p>2. 2 + 2 = ?</p>
<input type="radio" name="q2" value="4"> 4<br>
<input type="radio" name="q2" value="5"> 5<br>
<button type="submit">Submit</button>
</form>
<p id="result"></p>
<script>
document.getElementById("quizForm").addEventListener("submit", function(event) {
event.preventDefault();
let score = 0;
let answers = { q1: "Paris", q2: "4" };
</body>
</html>
🚀
if (profilePhoto.type !== "image/jpeg") alert("Profile photo must be JPG.");
Let me know if you need modifications!