mirror of
https://github.com/tmdinosaurcenter/kiosk-guestbook.git
synced 2025-04-04 03:11:23 -06:00
Add form instructions and make email optional
- Display brief instructions above the guestbook form. - Update validation: require first name, last name, and location; make email optional. - Remove the 'required' attribute from the email input field. - Provide context in the UI so users understand why email is optional.
This commit is contained in:
parent
4623e014a5
commit
9ce656a963
12
app.py
12
app.py
@ -18,7 +18,7 @@ def init_db():
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
first_name TEXT NOT NULL,
|
||||
last_name TEXT NOT NULL,
|
||||
email TEXT NOT NULL,
|
||||
email TEXT,
|
||||
location TEXT NOT NULL,
|
||||
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
)
|
||||
@ -42,11 +42,11 @@ def index():
|
||||
email = request.form.get('email', '').strip()
|
||||
location = request.form.get('location', '').strip()
|
||||
|
||||
# Basic validation checks
|
||||
if not (first_name and last_name and email and location):
|
||||
error = "All fields are required."
|
||||
logger.warning("Validation error: Missing required fields.")
|
||||
elif not is_valid_email(email):
|
||||
# Basic validation checks (email is optional)
|
||||
if not (first_name and last_name and location):
|
||||
error = "First name, last name, and location are required."
|
||||
logger.warning("Validation error: Missing required fields (first name, last name, location).")
|
||||
elif email and not is_valid_email(email):
|
||||
error = "Invalid email address."
|
||||
logger.warning("Validation error: Invalid email address '%s'.", email)
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
.scrolling-content {
|
||||
display: inline-block;
|
||||
padding: 10px;
|
||||
/* Adjust the animation duration to control speed */
|
||||
animation: scroll-left 20s linear infinite;
|
||||
}
|
||||
|
||||
@ -42,6 +41,12 @@
|
||||
<div class="container mt-5 mb-5">
|
||||
<h1 class="mb-4">Museum Visitor Guestbook</h1>
|
||||
|
||||
<!-- Brief instructions for the form -->
|
||||
<div class="alert alert-info" role="alert">
|
||||
Please fill in your details below. First name, last name, and location are required.
|
||||
Providing your email is optional, but it helps us follow up if needed.
|
||||
</div>
|
||||
|
||||
{% if error %}
|
||||
<div class="alert alert-danger" role="alert">
|
||||
{{ error }}
|
||||
@ -58,8 +63,8 @@
|
||||
<input type="text" class="form-control" id="last_name" name="last_name" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">Email:</label>
|
||||
<input type="email" class="form-control" id="email" name="email" required>
|
||||
<label for="email" class="form-label">Email (Optional):</label>
|
||||
<input type="email" class="form-control" id="email" name="email">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="location" class="form-label">Location:</label>
|
||||
|
Loading…
x
Reference in New Issue
Block a user