Output 4: Form Validation

Registration Form

Fill out the form with real-time validation

Validation Rules: Username required, valid email format, password minimum 6 characters, and passwords must match.

Source Code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Form Validation</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <form id="registrationForm">
        <label for="username">Username:</label>
        <input type="text" id="username" required>
        
        <label for="email">Email:</label>
        <input type="email" id="email" required>
        
        <label for="password">Password:</label>
        <input type="password" id="password" required>
        
        <label for="confirmPassword">Confirm Password:</label>
        <input type="password" id="confirmPassword" required>
        
        <button type="submit">Submit</button>
        <div id="error-message" style="color: red;"></div>
    </form>
    <script src="script.js"></script>
</body>
</html>