Written by: Geoffrey Callaghan
Registration Forms 101 Definition, Types, Use-Cases And More
Registration Forms 101 Definition, Types, Use-Cases And More
A registration form is a structured document that allows users to input their personal information for various purposes, such as signing up for a service, event, or account. It typically includes fields for basic details like name, email, and password, but can also collect more specific information depending on the context.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>User Registration Form</title>
<style>
body { font-family: Arial, sans-serif; background-color: #f4f4f4; }
.container { max-width: 500px; margin: 50px auto; padding: 20px; background: #fff; border-radius: 8px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); }
h2 { text-align: center; }
label { display: block; margin-bottom: 5px; }
input[type="text"], input[type="email"], input[type="password"] { width: 100%; padding: 10px; margin-bottom: 10px; border: 1px solid #ccc; border-radius: 4px; }
.btn { background-color: #5cb85c; color: white; padding: 10px; border: none; border-radius: 4px; cursor: pointer; }
.btn:hover { background-color: #4cae4c; }
</style>
</head>
<body>
<div class="container">
<h2>User Registration</h2>
<form action="/submit-registration" method="POST">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<label for="confirm_password">Confirm Password:</label>
<input type="password" id="confirm_password" name="confirm_password" required>
<button type="submit" class="btn">Register</button>
</form>
</div>
</body>
</html>
document.addEventListener('DOMContentLoaded', () => {
const form = document.querySelector('form');
const password = document.getElementById('password');
const confirmPassword = document.getElementById('confirm_password');
form.addEventListener('submit', (event) => {
if (password.value !== confirmPassword.value) {
alert('Passwords do not match.');
event.preventDefault();
}
});
});
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.post('/submit-registration', (req, res) => {
const { name, email, password, confirm_password } = req.body;
if (password !== confirm_password) {
return res.status(400).send('Passwords do not match.');
}
// Save user data to the database (pseudo code)
// saveUser({ name, email, password });
res.send('Registration successful!');
});
app.listen(3000, () => {
console.log('Server running on http://localhost:3000');
});
By following these steps and using the provided template, you can create effective and secure registration forms tailored to your specific use-case.