<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Masterclass Signup</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin-top: 50px;
}
.container {
border: 1px solid black;
display: inline-block;
padding: 20px;
border-radius: 8px;
}
input {
margin: 5px 0;
padding: 8px;
width: 80%;
}
.error {
color: red;
font-size: 0.9em;
}
.success {
color: green;
font-weight: bold;
}
button {
padding: 10px 20px;
margin-top: 10px;
cursor: pointer;
}
</style>
</head>
<body id="bbb">
<h1 style="color:red">Ready to sign up for your very own MASTERCLASS?</h1>
<p style="color:blue">Sign up now!</p>
<div class="container">
<input type="text" id="name" placeholder="Full name" required><br><br>
<input type="email" id="email" placeholder="Enter your email" required><br>
<p id="emailError" class="error"></p>
<input type="tel" id="phone" placeholder="Phone no. (e.g., +1234567890)" required><br>
<p id="phoneError" class="error"></p>
<button onclick="submitForm()">Submit</button>
</div>
<p id="result"></p>
<br>
<button hidden id="confirmBtn" onclick="hideBody()">Confirm</button>
<script>
function submitForm() {
const name = document.getElementById("name").value.trim();
const email = document.getElementById("email").value.trim();
const phone = document.getElementById("phone").value.trim();
const emailError = document.getElementById("emailError");
const phoneError = document.getElementById("phoneError");
const result = document.getElementById("result");
const confirmBtn = document.getElementById("confirmBtn");
emailError.innerText = "";
phoneError.innerText = "";
result.innerText = "";
let isEmailValid = false;
let isPhoneValid = false;
// Updated regex for ALL valid email formats
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
const phoneRegex = /^\+\d{10,15}$/;
if (emailRegex.test(email)) {
isEmailValid = true;
} else {
emailError.innerText = "Please enter a valid email address.";
}
if (phoneRegex.test(phone)) {
isPhoneValid = true;
} else {
phoneError.innerText = "Please enter a valid phone number starting with '+'.";
}
if (isEmailValid && isPhoneValid) {
result.className = "success";
result.innerHTML = `${name}<br>${email}<br>${phone}`;
confirmBtn.hidden = false;
} else {
result.className = "error";
result.innerText = "⚠️ PLS RE-ENTER CORRECT EMAIL OR PHONE NO";
}
}
function hideBody() {
document.body.style.display = 'none';
}
</script>
</body>
</html>