Untitled
unknown
plain_text
a year ago
1.6 kB
2
Indexable
Never
<!DOCTYPE html> <html> <head> <title>Registration Form</title> <script> function validateForm() { var name = document.forms["registrationForm"]["name"].value; var email = document.forms["registrationForm"]["email"].value; var password = document.forms["registrationForm"]["password"].value; if (name == "") { alert("Name must be filled out"); return false; } if (email == "") { alert("Email must be filled out"); return false; } else if (!isValidEmail(email)) { alert("Invalid email address"); return false; } if (password == "") { alert("Password must be filled out"); return false; } else if (password.length < 8) { alert("Password must be at least 8 characters long"); return false; } return true; } function isValidEmail(email) { var emailPattern = /^\w+@[a-zA-Z_]+\.[a-zA-Z]{2,3}$/; return emailPattern.test(email); } </script> </head> <body> <h2>Registration Form</h2> <form name="registrationForm" onsubmit="return validateForm()" method="post"> Name: <input type="text" name="name"><br><br> Email: <input type="text" name="email"><br><br> Password: <input type="password" name="password"><br><br> <input type="submit" value="Register"> </form> </body> </html>