CSCI 4513
Week 1, Lecture 2
Odin sacrificed his eye to gain profound wisdom, just as learning web development demands sacrifice of time and comfort for deep understanding.
The Tale:
At the roots of Yggdrasil lies Mimir's Well, a spring of profound wisdom guarded by Mimir. Though already the Allfather and wisest of the Aesir, Odin sought even greater knowledge. When he journeyed to drink from the well, Mimir demanded a steep price: one of Odin's eyes.
Without hesitation, Odin plucked out his own eye and cast it into the well's depths. In exchange, he gained wisdom that transformed him from a powerful god into the wisest being in all the Nine Realms—foresight to see beyond the immediate and prepare for Ragnarök itself.
Tip: Click the gear icon to set playback speed to 1.5x
Click each card to reveal thoughts!
What are you willing to "sacrifice" this semester to gain web development skills?
Consider: Time spent on social media, gaming, or leisure activities. Comfort of relying on what you already know. Short-term frustration for long-term capability. Like Odin's eye, what you give up enables what you gain.
Odin already had significant power before seeking Mimir's Well. Why do experienced developers continue learning new technologies?
Consider: Technology evolves constantly. Today's best practices become tomorrow's legacy code. Staying relevant requires perpetual learning. Deep expertise in fundamentals makes learning new frameworks faster, not slower.
What "permanent testaments" will you create this semester—projects, portfolios, or skills that remain after the course ends?
Consider: A portfolio website showcasing your work. GitHub repos that demonstrate your learning journey. Problem-solving skills that transfer across languages. The confidence to tackle unfamiliar technical challenges.
Like Mimir's head and Odin's eye, what are you willing to leave in the "knowledge well" for those who may drink from the waters in the future? Or did you think you were the only Odin?
Consider: To live communally great lives, we have to plant trees we won't live to harvest or even sit under.
Forms are your user's gateway into your backend—the user provides data in a form, and you do stuff with it.
I've built a real API for this class! You can submit forms to it and see actual responses.
GET /api/search
Search programming resources
Query params: ?q=javascript
POST /api/messages
Post to our class message board
Fields: username, message
Base URL: https://aw.profbobby.com/api/
A tool for testing APIs without writing code. Perfect for exploring endpoints before building forms.
https://aw.profbobby.com/api/search?q=javascripthttps://aw.profbobby.com/api/messages{
"username": "YourName",
"message": "Hello from Postman!"
}
Base URL: https://aw.profbobby.com/api/
This is a hands-on lecture! You should be coding as we go.
🚨 Can't keep up? RAISE YOUR HAND!
Don't fall behind silently. Ask questions until you figure out the issue. That's what I'm here for!
The <form> element is a container that wraps all inputs users interact with.
<!-- Using our class API! -->
<form action="https://aw.profbobby.com/api/messages" method="post">
<!-- form controls go here -->
</form>
Base URL: https://aw.profbobby.com/api/
<form action="https://aw.profbobby.com/api/messages" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username">
<label for="message">Message:</label>
<textarea id="message" name="message"></textarea>
</form>
for attribute matches input idname attribute is required for submission<label for="username">Username:</label>
<input
type="text"
id="username"
name="username"
placeholder="Enter your username..."
>
name attribute, the input will be ignored when the form is submitted!
<!-- Text Input -->
<input type="text" name="username">
<!-- Email Input (validates format) -->
<input type="email" name="email" placeholder="you@example.com">
<!-- Password Input (masks characters) -->
<input type="password" name="password">
<!-- Number Input (only accepts numbers) -->
<input type="number" name="quantity" min="1" max="10">
<!-- Date Input (date picker calendar) -->
<input type="date" name="dob">
For multi-line text input (comments, reviews, descriptions):
<label for="bio">Biography:</label>
<textarea
id="bio"
name="bio"
rows="20"
cols="60"
>Some initial content</textarea>
<select name="car">
<option value="tesla">Tesla</option>
<option value="volvo" selected>Volvo</option>
<option value="bmw">BMW</option>
</select>
<!-- Grouped Options -->
<select name="fashion">
<optgroup label="Clothing">
<option value="t_shirt">T-Shirts</option>
<option value="sweater">Sweaters</option>
</optgroup>
<optgroup label="Foot Wear">
<option value="sneakers">Sneakers</option>
<option value="boots">Boots</option>
</optgroup>
</select>
<input type="radio"
id="adult"
name="ticket_type"
value="adult"
checked>
<label for="adult">Adult</label>
<input type="radio"
id="child"
name="ticket_type"
value="child">
<label for="child">Child</label>
Same name = same group
<input type="checkbox"
id="sausage"
name="topping"
value="sausage">
<label for="sausage">
Sausage
</label>
<input type="checkbox"
id="pepperoni"
name="topping"
value="pepperoni">
<label for="pepperoni">
Pepperoni
</label>
<!-- Submit Button (submits form) -->
<button type="submit">Submit</button>
<!-- Reset Button (clears all form data) -->
<button type="reset">Reset</button>
<!-- Generic Button (for JavaScript) -->
<button type="button">Click to Toggle</button>
type="button" for non-submit buttons in forms to avoid unwanted form submissions!
<fieldset>
<legend>Contact Details</legend>
<label for="name">Name:</label>
<input type="text" id="name" name="name">
<label for="email">Email:</label>
<input type="email" id="email" name="email">
</fieldset>
<fieldset>
<legend>Delivery Details</legend>
<label for="address">Street Address:</label>
<input type="text" id="address" name="address">
<label for="city">City:</label>
<input type="text" id="city" name="city">
</fieldset>
Groups related inputs into logical, visually distinct sections
Each browser has different default styles for form controls. Must override for consistency.
Validations set constraints that determine what data users can enter. When rules are broken, feedback appears to help users fix the issue.
<!-- Required Field -->
<label for="email">Email: *</label>
<input type="email" id="email" name="email" required>
<!-- Minimum Length -->
<label for="username">Username:</label>
<input type="text" id="username" name="username"
minlength="3">
<!-- Maximum Length -->
<textarea name="post" maxlength="280"></textarea>
<!-- Combined Validations -->
<textarea name="comment"
minlength="10"
maxlength="500"
required></textarea>
Always indicate required fields with * and explain what it means!
<!-- Min/Max for Numbers -->
<label for="quantity">Quantity:</label>
<input type="number" id="quantity" name="quantity"
min="1" max="6">
<!-- Pattern Validation (Regular Expression) -->
<label for="zipcode">Zip Code:</label>
<input type="text"
id="zipcode"
name="zipcode"
pattern="[0-9]{5}(-[0-9]{4})?"
placeholder="12345 or 12345-6789">
<!-- Email & URL have built-in patterns -->
<input type="email" name="email">
<input type="url" name="website">
Pattern breakdown: [0-9]{5}(-[0-9]{4})?
[0-9] = any digit 0-9{5} = exactly 5 times(-[0-9]{4}) = dash + 4 digits? = optional (0 or 1 times)Result: Matches 12345 or 12345-6789
[a-z] = lowercase letter[A-Z] = uppercase letter[a-zA-Z] = any letter. = any character+ = one or more* = zero or more/* Valid inputs get green border */
input:valid {
border: 2px solid green;
}
/* Invalid inputs get red border */
input:invalid {
border: 2px solid red;
}
/* Focused inputs get blue border and shadow */
input:focus {
border: 2px solid blue;
box-shadow: 0 0 5px rgba(0, 100, 255, 0.5);
}
/* Password confirmation doesn't match */
input[type="password"]:invalid {
border: 2px solid #cc0000;
}
Use :valid, :invalid, and :focus pseudo-classes for visual feedback
Client-side validation improves UX but is NOT secure. Always validate on the server too! Users can bypass client-side validations.
Let's test our knowledge with a real form submission!
aw.profbobby.com/api/messagesusername and messageView all messages: aw.profbobby.com/api/messages
Base URL: https://aw.profbobby.com/api/
Build a sign-up form for an imaginary service that demonstrates everything you've learned about HTML forms, validation, and styling.
#596D48 (matches background tones)#E5E7EB (light gray):invalid:focus📅 Next Class: Intermediate CSS - Grid
📝 Homework: Sign-up Form
🔗 Resource: API Playground - Practice API calls anytime!