# Build a Banking App Part 2: Build a Login and Registration Form
```mermaid
journey
title Your Form Development Journey
section HTML Foundation
Understand form elements: 3: Student
Learn input types: 4: Student
Master accessibility: 4: Student
section JavaScript Integration
Handle form submission: 4: Student
Implement AJAX communication: 5: Student
Process server responses: 5: Student
section Validation Systems
Create multi-layer validation: 5: Student
Enhance user experience: 5: Student
Ensure data integrity: 5: Student
```
## Pre-Lecture Quiz
[Pre-lecture quiz](https://ff-quizzes.netlify.app/web/quiz/43)
You don ever fill form for internet before and e no gree accept your email format? Or you don lose all di information wen you click submit? We all don face dis kain wahala before.
Forms na bridge wey dey connect your users and your app functionality. Like how air traffic controllers take guide plane well so dem fit land safe, better-designed forms dey give clear feedback and e dey stop costly mistakes. Bad forms fit make users waka commot quick quick like how communication fail for busy airport.
For dis lesson, we go turn your static banking app to interactive application. You go learn how to build forms wey go check user input well, dey talk with servers, and give better feedback. Think am like building control interface weh go allow users guide your app features.
By di end, you go get complete login and registration system wey get validation wey dey guide users make dem succeed no be make dem frustrated.
```mermaid
mindmap
root((Form Development))
HTML Foundation
Semantic Elements
Input Types
Accessibility
Label Association
User Experience
Validation Feedback
Error Prevention
Loading States
Success Messaging
JavaScript Integration
Event Handling
AJAX Communication
Data Processing
Error Management
Validation Layers
HTML5 Validation
Client-side Logic
Server-side Security
Progressive Enhancement
Modern Patterns
Fetch API
Async/Await
Form Data API
Promise Handling
```
## Prerequisites
Before we start to build forms, make sure sey everything set well. Dis lesson na continuation from di last one, so if you jump pass, you fit wan go back make sure di basics dey work well first.
### Required Setup
| Component | Status | Description |
|-----------|--------|-------------|
| [HTML Templates](../1-template-route/README.md) | โ Required | Your basic banking app structure |
| [Node.js](https://nodejs.org) | โ Required | JavaScript runtime for the server |
| [Bank API Server](../api/README.md) | โ Required | Backend service for data storage |
> ๐ก **Development Tip**: You go dey run two different servers at the same time โ one for your frontend banking app and anoda for backend API. Dis setup mirror how real-life development dey work where frontend and backend services dey independent.
### Server Configuration
**Your development environment go get:**
- **Frontend server**: Na im dey serve your banking app (usually port `3000`)
- **Backend API server**: Na im dey handle data storage and retrieval (port `5000`)
- **Both servers** fit run together without wahala
**To test your API connection:**
```bash
curl http://localhost:5000/api
# Wetin we expect make e respond: "Bank API v1.0.0"
```
**If you see di API version response, you ready to continue!**
---
## Understanding HTML Forms and Controls
HTML forms na how users dey talk to your web application. Think am like telegraph system weh connect far places for 19th century โ na communication protocol between user wahala and application response. When dem design am well, dem go catch errors, guide how user suppose enter data, and give better suggestions.
Today forms don better pass simple text inputs. HTML5 bring special input types wey dey handle email validation, number format, and date selection automatically. These improvements dey help both accessibility and mobile users.
### Essential Form Elements
**Building blocks every form need:**
```html
```
**Wetin dis code dey do:**
- **Creates** form container with unique id
- **Specifies** di HTTP method wey them go use submit data
- **Link** labels with inputs make e dey accessible
- **Get** submit button wey go process di form
### Modern Input Types and Attributes
| Input Type | Purpose | Example Usage |
|------------|---------|---------------|
| `text` | Normal text input | `` |
| `email` | Email validation | `` |
| `password` | Hidden text entry | `` |
| `number` | Number input | `` |
| `tel` | Phone number | `` |
> ๐ก **Modern HTML5 Advantage**: Using special input types mean automatic validation, correct mobile keyboards, and better accessibility support without extra JavaScript!
### Button Types and Behavior
```html
```
**Dis na wetin each button type dey do:**
- **Submit buttons**: Dey trigger form submission and send data go specified endpoint
- **Reset buttons**: Dey bring back all form fields to how dem start
- **Normal buttons**: No get default behaviour, need your own JavaScript to work
> โ ๏ธ **Important Note**: The `` element na self-closing. You no need to close am like ``. Best practice now na to write just `` without slash.
### Building Your Login Form
Make we create practical login form wey show modern HTML form way of doing things. We go start with basic structure then add accessibility and validation slowly.
```html
Bank App
Login
```
**Breakdown of wetin dey happen here:**
- **Organizes** form using semantic HTML5 elements
- **Group** related parts inside `div` with good class names
- **Link** labels with inputs using `for` and `id`
- **Include** modern attributes like `autocomplete` and `placeholder` for better user experience
- **Add** `novalidate` so JavaScript fit handle validation, no be browser default
### The Power of Proper Labels
**Why labels dey important for modern web development:**
```mermaid
graph TD
A[Label Element] --> B[Screen Reader Support]
A --> C[Click Target Expansion]
A --> D[Form Validation]
A --> E[SEO Benefits]
B --> F[Accessible to all users]
C --> G[Betta mobile experience]
D --> H[Clear error messaging]
E --> I[Betta search ranking]
```
**Wetin good labels dey do:**
- **Allow** screen readers to announce form fields well well
- **Expand** clickable area (click label, input go get focus)
- **Make** mobile use easier with bigger touch targets
- **Support** form validation with better error messages
- **Improve** SEO cos e give semantic meaning to form
> ๐ฏ **Accessibility Goal**: Every form input suppose get label wey match am. This small thing go make your forms usable by everybody, including those wey get disabilities, and e go make experience better for all users.
### Creating the Registration Form
Registration form need plenty detail to make full user account. Make we build am with modern HTML5 features plus better accessibility.
```html
Register
```
**For di form above, we don:**
- **Organize** every field inside container divs for better styling and layout
- **Add** proper `autocomplete` attributes for browser autofill
- **Put** good placeholder text to help user input
- **Set** sensible defaults with `value` attribute
- **Use** validation attributes like `required`, `maxlength`, and `min`
- **Use** `type="number"` for balance field with decimal support
### Exploring Input Types and Behavior
**Modern input types get better features:**
| Feature | Benefit | Example |
|---------|---------|----------|
| `type="number"` | Numeric keypad for mobile | Easier to enter balance |
| `step="0.01"` | Control decimal precision | Allow cents for money |
| `autocomplete` | Browser autofill | Faster to fill form |
| `placeholder` | Context hints | Help user know what to enter |
> ๐ฏ **Accessibility Challenge**: Try to move around form using only your keyboard! Use `Tab` to waka between fields, `Space` to check box, and `Enter` to submit. Dis experience go help you understand how screen reader users take use forms.
### ๐ **Pedagogical Check-in**
**Form Foundation Understanding**: Before you start JavaScript, make sure you sabi:
- โ How semantic HTML dey create accessible form structure
- โ Why input types dey important for mobile keyboards and validation
- โ Relationship between labels and form controls
- โ How form attributes dey affect browser default behaviour
**Quick Self-Test**: Wetin happen if you submit form without JavaScript?
*Answer: Browser go do default submission, normally e go redirect to action URL*
**HTML5 Form Benefits**: Modern forms get:
- **Built-in Validation**: Automatic email and number format checking
- **Mobile Optimization**: Proper keyboards for input types
- **Accessibility**: Screen reader support and keyboard navigation
- **Progressive Enhancement**: E go still work even if JavaScript no dey
## Understanding Form Submission Methods
When person fill your form and click submit, that data must go somewhere โ normally server weh fit save am. Several ways dey do dis, and to sabi which one to use go help you avoid problem later.
Make we look wetin really happen when person click submit button.
### Default Form Behavior
First, make we see wetin happen with normal form submission:
**Test your forms:**
1. Click the *Register* button for your form
2. Look di address bar your browser
3. See how di page fresh and data enter for URL

### HTTP Methods Comparison
```mermaid
graph TD
A[Form Submission] --> B{HTTP Method}
B -->|GET| C[Data for URL]
B -->|POST| D[Data for Request Body]
C --> E[You fit see am for address bar]
C --> F[Data size no too big]
C --> G[You fit bookmark am]
D --> H[Hidden commot for URL]
D --> I[Data capacity big]
D --> J[More secure]
```
**Understand di difference:**
| Method | Use Case | Data Location | Security Level | Size Limit |
|--------|----------|---------------|----------------|-------------|
| `GET` | Search and filters | URL parameters | Low (everybody fit see) | ~2000 characters |
| `POST` | User accounts, sensitive info | Request body | Higher (hidden) | No real limit |
**Summary of difference:**
- **GET**: Data dey go URL as query parameters (good for search)
- **POST**: Data dey inside request body (better for sensitive info)
- **GET problems**: Small size limit, data dey show, dey save in browser history
- **POST pros**: Fit large data, private, fit upload files
> ๐ก **Best Practice**: Use `GET` for search and filters (data retrieval), use `POST` for user registration, login, and data creation.
### Configuring Form Submission
Make we setup your registration form so e fit talk well with backend API using POST method:
```html
```
**Understanding improved validation:**
- **Combine** required field marks with useful descriptions
- **Get** `pattern` attributes for format check
- **Add** `title` attributes for accessibility and tooltips
- **Put** helper text to guide user input
- **Use** semantic HTML structure for better accessibility
### Advanced Validation Rules
**What each validation rule do:**
| Field | Validation Rules | User Benefit |
|-------|------------------|--------------|
| Username | `required`, `minlength="3"`, `maxlength="20"`, `pattern="[a-zA-Z0-9_]+"` | Make sure id valid and unique |
| Currency | `required`, `maxlength="3"`, `pattern="[A-Z$โฌยฃยฅโน]+"` | Accept common currency signs |
| Balance | `min="0"`, `step="0.01"`, `type="number"` | Stop negative balances |
| Description | `maxlength="100"` | Reasonable limit for text |
### Test Validation Behavior
**Try these validation cases:**
1. **Submit** form wit empty required fields
2. **Put** username wey too short (less than 3)
3. **Try** special characters for username
4. **Input** negative number for balance

**Wetin you go see:**
- **Browser show** native validation messages
- **Style go change** based on `:valid` and `:invalid`
- **Form no go submit** until all validation pass
- **Focus go move** to first invalid field automatically
### Client-Side vs Server-Side Validation
```mermaid
graph LR
A[Client-Side Validation] --> B[Quick Quick Feedback]
A --> C[Beta UX]
A --> D[Reduced Server Load]
E[Server-Side Validation] --> F[Security]
E --> G[Data Integrity]
E --> H[Business Rules]
A -.-> I[Bote Dem Dey Needed]
E -.-> I
```
**Why you need both validation levels:**
- **Client-side validation**: Quick feedback and better user experience
- **Server-side validation**: Secure and handle complex rules
- **Together**: Make app strong, user-friendly, and secure
- **Progressive enhancement**: E still work if JavaScript off
> ๐ก๏ธ **Security Reminder**: No trust client-side validation alone! Bad people fit bypass am, so always do server-side validation for safety and data integrity.
### โก **Wetyn You Fit Do in Next 5 Minutes**
- [ ] Test your form with wrong data to see validation messages
- [ ] Try submit form with JavaScript off to see HTML5 validation
- [ ] Open browser DevTools check form data wey dey send to server
- [ ] Try different input types to see mobile keyboard change
### ๐ฏ **Wetyn You Fit Achieve This Hour**
- [ ] Finish post-lesson test and understand form handling concepts
- [ ] Implement full validation challenge with instant feedback
- [ ] Add CSS style to make professional looking forms
- [ ] Add error handling for duplicate usernames and server issues
- [ ] Add password confirmation with matching validation
### ๐ **Your Week-Long Form Mastery Journey**
- [ ] Build full banking app with advanced form features
- [ ] Add file upload support for profile pics or documents
- [ ] Create multi-step forms with progress and state control
- [ ] Build dynamic forms wey adjust based on user choice
- [ ] Add form autosave and recovery for better user experience
- [ ] Add advanced validation like email and phone formatting
### ๐ **Your Month-Long Frontend Development Mastery**
- [ ] Build complex form apps wit conditional logic and workflow
- [ ] Learn form libraries and frameworks for faster development
- [ ] Master accessibility guidelines and inclusive design
- [ ] Implement i18n and localization for global forms
- [ ] Create reusable form component libraries and design systems
- [ ] Contribute to open source form projects and share best practice
## ๐ฏ Your Form Development Mastery Timeline
```mermaid
timeline
title Form Development & User Experience Learning Progression
section HTML Foundation (15 minutes)
Semantic Forms: Form elements
: Input types
: Labels and accessibility
: Progressive enhancement
section JavaScript Integration (25 minutes)
Event Handling: Form submission
: Data collection
: AJAX communication
: Async/await patterns
section Validation Systems (35 minutes)
Multi-layer Security: HTML5 validation
: Client-side logic
: Server-side verification
: Error handling
section User Experience (45 minutes)
Interface Polish: Loading states
: Success messaging
: Error recovery
: Accessibility features
section Advanced Patterns (1 week)
Professional Forms: Dynamic validation
: Multi-step workflows
: File uploads
: Real-time feedback
section Enterprise Skills (1 month)
Production Applications: Form libraries
: Testing strategies
: Performance optimization
: Security best practices
```
### ๐ ๏ธ Your Form Development Toolkit Summary
After dis lesson, you don master:
- **HTML5 Forms**: Good structure, input types, and accessibility
- **JavaScript Form Handling**: Events, data collection, AJAX communication
- **Validation Architecture**: Multi-layer checks for security and UX
- **Asynchronous Programming**: Modern fetch API and async/await
- **Error Management**: Complete error catching and user feedback
- **User Experience Design**: Loading, success messages, error recovery
- **Progressive Enhancement**: Forms work on all browsers and setups
**Real-World Applications**: Your form skill fit:
- **E-commerce Apps**: Checkout, signup, payment forms
- **Enterprise Software**: Data entry, reports, workflow apps
- **Content Management**: Publishing, user content, admin tools
- **Finance Apps**: Banking, investments, transactions
- **Healthcare**: Patient portals, scheduling, medical forms
- **Education**: Course sign-up, assessments, LMS
**Professional Skills You Get**:
- **Design** accessible forms for all users including disabled
- **Implement** secure validation to stop data corruption and attacks
- **Create** responsive UI wey give clear feedback and guide users
- **Debug** complex forms using browser dev tools and network checks
- **Optimize** form performance through data handling and validation
**Frontend Development Concepts You Master**:
- **Event-Driven Architecture**: User interaction and response
- **Asynchronous Programming**: Non-blocking server talk and error handle
- **Data Validation**: Client and server side security and integrity
- **User Experience Design**: Easy interfaces wey guide success
- **Accessibility Engineering**: Inclusive design for diverse needs
**Next Steps**: You ready to learn advanced form libraries, complex validation, or build enterprise data systems!
๐ **Achievement Unlocked**: You don build complete form system with pro validation, error handling, and UX patterns!
---
---
## GitHub Copilot Agent Challenge ๐
Use Agent mode to finish this challenge:
**Description:** Make the registration form better with full client-side validation and user feedback. Dis challenge go help you practice validation, error handling, and improve user experience with interactive feedback.
**Prompt:** Create a complete form validation system for the registration form wey get: 1) Real-time validation feedback for every field as di user dey type, 2) Custom validation messages wey dey show under every input field, 3) Password confirmation field wey dey check if dem match, 4) Visual indicators (like green checkmarks for valid fields and red warnings for invalid ones), 5) Submit button wey go only active when all validations don pass. Use HTML5 validation attributes, CSS to style the validation states, and JavaScript for the interactive behavior.
Learn more about [agent mode](https://code.visualstudio.com/blogs/2025/02/24/introducing-copilot-agent-mode) here.
## ๐ Challenge
Show error message for the HTML if di user don already exist.
Here be example of how the final login page fit look after small styling:

## Post-Lecture Quiz
[Post-lecture quiz](https://ff-quizzes.netlify.app/web/quiz/44)
## Review & Self Study
Developers don become very creative for their form building, especially for validation strategies. Learn about different form flows by checking [CodePen](https://codepen.com); fit you find some interesting and inspiring forms?
## Assignment
[Style your bank app](assignment.md)
---
**Disclaimer**:
Dis document na wetin AI translation service [Co-op Translator](https://github.com/Azure/co-op-translator) help translate. Even though we dey try make am correct, abeg sabi say automated translation fit get errors or no too correct sometimes. The original document for im own language na di correct one wey you suppose trust. For important information, make person wey sabi translation do am human way. We no go responsible if person misunderstand or misinterpret anything because of dis translation.