Lesson 6 Advanced Web Programming

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/41

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 3:32 PM on 9/3/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

42 Terms

1
New cards

Form

is a user interface that collects information from users.

2
New cards

Common examples

Login forms

Registration forms

Contact forms

Search forms

Checkout forms

Student enrollment forms

Feedback and survey forms

3
New cards

React Forms

  • use standard HTML form elements, but their values and behaviors can be managed by React components.

  • supports both controlled and uncontrolled form elements, but controlled components are commonly taught because React state becomes the primary source of the input value.


4
New cards

Example of React Forms/ React Form Can:

Store form values in component state.

Update values when users type.

Validate user input.

Display error messages.

Submit data to an API or server.

Clear the form after submission.

Disable buttons while submitting

5
New cards

HTML Forms

  • Browser manages from data

  • Page reload after submit

  • Uses DOM

  • Less interactive

  • Validation mostly after submission


6
New cards

React Forms

  • React manages from data

  • No page reload

  • Use State

  • Highly interactive

  • Can validate while typing


7
New cards

Traditional HTML form

The browser directly submits the data to the server.

<p><span style="font-family: &quot;Bookman Old Style&quot;;">The browser directly submits the data to the server.</span></p>
8
New cards

React form

React controls:

The input value

Input changes

Validation

Submission behavior

User feedback

<p><span style="font-family: &quot;Bookman Old Style&quot;;"><strong>React controls:</strong></span></p><p><span style="font-family: Arial;">• </span><span style="font-family: &quot;Bookman Old Style&quot;;">The input value</span></p><p><span style="font-family: Arial;">• </span><span style="font-family: &quot;Bookman Old Style&quot;;">Input changes</span></p><p><span style="font-family: Arial;">• </span><span style="font-family: &quot;Bookman Old Style&quot;;">Validation</span></p><p><span style="font-family: Arial;">• </span><span style="font-family: &quot;Bookman Old Style&quot;;">Submission behavior</span></p><p><span style="font-family: Arial;">• </span><span style="font-family: &quot;Bookman Old Style&quot;;">User feedback</span></p>
9
New cards

Common Form Elements in React

  • Text Input

  • Password Input

  • Email Input

  • Number Input

  • Textarea

  • Select Dropdown

  • Radio Button

  • Checkbox

  • Submit Button


10
New cards

Text Input

allows users to enter a single line of text.

<p><span style="font-family: &quot;Bookman Old Style&quot;;">allows users to enter a single line of text.</span></p>
11
New cards

Password Input

hides the characters entered to protect sensitive

<p><span style="font-family: &quot;Bookman Old Style&quot;;">hides the characters entered to protect sensitive</span></p>
12
New cards

Email Input

is used to collect email addresses and provides basic email format validation.

<p><span style="font-family: &quot;Bookman Old Style&quot;;">is used to collect email addresses and provides basic email format validation.</span></p>
13
New cards

Number Input

allows users to enter numeric values only.

<p><span style="font-family: &quot;Bookman Old Style&quot;;">allows users to enter numeric values only.</span></p>
14
New cards

Textarea

allows users to enter multiple lines of text.

<p><span style="font-family: &quot;Bookman Old Style&quot;;">allows users to enter multiple lines of text.</span></p>
15
New cards

Select Dropdown

lets users choose one option from a list.

<p><span style="font-family: &quot;Bookman Old Style&quot;;">lets users choose one option from a list.</span></p>
16
New cards

Radio Button

allow users to select only one option from a group.

<p><span style="font-family: &quot;Bookman Old Style&quot;;">allow users to select only one option from a group.</span></p>
17
New cards

Checkbox

allows users to select one or more options.

<p><span style="font-family: &quot;Bookman Old Style&quot;;">allows users to select one or more options.</span></p>
18
New cards

Submit Button

sends the form data for processing.

<p><span style="font-family: &quot;Bookman Old Style&quot;;">sends the form data for processing.</span></p>
19
New cards

Controlled Components

Input value comes from State

State updates every time the user types

20
New cards

React Forms Handling

refers to the way a React application captures, manages, validates, and

submits user input from forms such as login pages, registration forms, search bars, and contact forms.

21
New cards

Why Form Handling is Important

Forms are one of the most common ways users interact with web applications. They allow users to:

Log in to an account

Register a new account

Search for information

Submit feedback

Upload files

Place order

provides a structured way to handle these interactions efficiently.


22
New cards

Types of Form Handling in React

Controlled Components

Uncontrolled Components

23
New cards

Controlled Componnents (most common)

  • is a form elementwhose value is controlled by React's state.

  • The input field always reflects the current state, and any changes made by the user update the state.


24
New cards

How Controlled Components work in Form handling in React

Create a state variable using useState.

Connect the input's value to the state.

Update the state whenever the user types

using the onChange event.

25
New cards

Uncontrolled Components

  • stores form data inside the DOM instead of React state.

  • React accesses the value only when needed using a ref.


26
New cards

Advantage and Disadvantage of Form Handling in React

Advantages

Less code

Slightly better performance for very large forms

Disadvantages

Harder to validate

Less React control

Not commonly used in modern React applications

27
New cards

Form Validation

checks the data entered by the user before the application accepts or submits it. It ensures that the input follows the required rules.

28
New cards

Example of Form Validation

The name must not be empty.

The email must have a valid format.

The password must contain at least eight characters.

The password and confirmation password must match.

The age must be within an acceptable range.

React commonly manages form values and validation messages using component state.

29
New cards

Why Form Validation is Important

Form validation helps:

Prevent incomplete form submissions.

Reduce incorrect user information.

Improve data accuracy.

Provide immediate feedback.

Improve user experience.

Reduce unnecessary server requests.

Protect the application from unexpected input.

30
New cards

Types of Form Validation

  1. Client Side Validation

  2. Server Side Validation


31
New cards

Client Side Validation

Validation happens inside the user's browser before the data is sent to the server.

improves usability, but server-side validation is still required

because browser-side rules can be bypassed.

32
New cards

Example of Client side Validation

Required fields

Email format

Minimum password length

Matching passwords

33
New cards

Server Side Validation

happens on the server after the form data is submitted.

34
New cards

Example of Server Side Validation

Checking whether an email already exists

Checking login credentials

Validating database records

Verifying user permissions

35
New cards

HTML Built-in Validation

  • Required

  • minLength

  • maxLength

  • min

  • max

  • pattern

  • type=”email”


36
New cards

Required

prevents the form from being submitted if the field is

empty.

<p><span style="font-family: &quot;Bookman Old Style&quot;;">prevents the form from being submitted if the field is</span></p><p><span style="font-family: &quot;Bookman Old Style&quot;;">empty.</span></p>
37
New cards

Email Validation

type="email" checks if the input is in a valid email format.

<p><span style="font-family: &quot;Bookman Old Style&quot;;">type="email" checks if the input is in a valid email format.</span></p>
38
New cards

Password Length Validation

The password must be between 8 and 20 characters.

<p><span style="font-family: &quot;Bookman Old Style&quot;;">The password must be between <strong>8 and 20 characters</strong>.</span></p>
39
New cards

Number Validation

Only numbers between 18 and 60 are accepted.

<p><span style="font-family: &quot;Bookman Old Style&quot;;">Only numbers between 18 and 60 are accepted.</span></p>
40
New cards

Pattern Validation

ensures that the user's input follows a specific format by using a pattern (regular expression or regex). If the input does not match the required pattern, the form will not be submitted.

<p><span style="font-family: &quot;Bookman Old Style&quot;;">ensures that the user's input follows a <strong>specific format </strong>by using a pattern (regular expression or regex). If the input does not match the required pattern, the form will not be submitted.</span></p>
41
New cards

Custom React Form Validation

is the process of creating your own validation rules using JavaScript and

React instead of relying on the browser's built-in validation. It allows developers to check user input based on specific application requirements and display customized error messages before the form is submitted.

42
New cards

Example of custom validation rules

Name must be at least 3 characters.

Password must contain an uppercase letter

and a number.

Password and Confirm Password must match.

Username must not contain spaces.