Toggle navigation
☰
HTML
CSS
Scripting
Database
<!DOCTYPE html> <html> <head> <title>Form Validation Example</title> <style> body { font-family: sans-serif; margin: 20px; } form { background: #f1f1f1; padding: 30px; border-radius: 12px; max-width: 350px; } .form-group { margin-bottom: 20px; } label { display: block; margin-bottom: 8px; font-weight: bold; } input { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } /* Optional: visual feedback for valid/invalid inputs */ input:invalid { border-color: #ff0000; } input:valid { border-color: #28a745; } input[type="submit"] { background-color: #007bff; color: white; border: none; cursor: pointer; margin-top: 10px; } input[type="submit"]:hover { background-color: #0056b3; } </style> </head> <body> <h3>Sign Up Form</h3> <p>Try submitting the form without filling it in, or try with an invalid email address.</p> <form action="/html/tags/html_form_tag.cfm"> <div class="form-group"> <label for="username">Username (min 4 chars):</label> <input type="text" id="username" name="username" required minlength="4"> </div> <div class="form-group"> <label for="email">Email Address:</label> <input type="email" id="email" name="email" required placeholder="name@example.com"> </div> <div class="form-group"> <label for="birth-year">Birth Year (1900-2023):</label> <input type="number" id="birth-year" name="birth-year" min="1900" max="2023"> </div> <input type="submit" value="Sign Up"> </form> </body> </html>