Front-End Design and Testing: JavaScript, DOM, Form Controls, and Validation

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

1/19

flashcard set

Earn XP

Description and Tags

Comprehensive practice flashcards covering core JavaScript concepts, HTML form integration, DOM tree manipulation, array methods, built-in objects, and Regular Expression validation.

20 Terms

1
New cards

Where should the external JavaScript <script> tag be placed in an HTML document, and why?

It should be placed before the closing </body> tag to ensure that HTML elements are fully loaded and exist in the browser before JavaScript attempts to access them.

2
New cards

How do textboxes, radio buttons, and checkboxes differ in how JavaScript reads their values?

A textbox stores a single value and is read directly using .value without a loop. Radio buttons exist in a group representing one selected option, requiring a for loop to check the .checked property and read its .value. Checkboxes allow multiple selections, requiring a for loop to inspect .checked and store all selected values into an array using push().

3
New cards

What is the 5-step algorithm for reading the selected option from a group of radio buttons in JavaScript?

  1. Get all radio buttons.
  2. Start from the first radio button.
  3. Check whether it is selected.
  4. If selected, save its value.
  5. Continue until all radio buttons are checked.
4
New cards

Why must objects and arrays be converted using JSON.stringify() before saving them to localStorage?

localStorage saves only text data, so objects and arrays must be converted into string format using JSON.stringify() before calling localStorage.setItem(), and parsed back into objects/arrays using JSON.parse() after retrieval with localStorage.getItem().

5
New cards

What is the complete form processing flow from user input to displaying data in an HTML table?

HTML Form → User enters data → Click Register → Validation → Read Values → Create Student Object → Store in Array → Save to Local Storage → Display HTML Table.

6
New cards

When adding a newly constructed table row to an existing HTML table using innerHTML, why is += used instead of =?

The += operator appends new rows while preserving existing rows, whereas = would overwrite the entire content and delete all previous rows.

7
New cards

What is the definition of JavaScript provided in the lecture?

JavaScript is a lightweight, interpreted scripting language used to make web pages interactive.

8
New cards

Where does JavaScript execute in web application architecture, and what is its role relative to the server?

JavaScript runs directly inside the user's browser, enabling web pages to become interactive and process tasks before communicating with the server.

9
New cards

What three sequential steps define the core flow of interactivity in JavaScript?

Event → Function → Update: A user action triggers an event, JavaScript executes the associated function, and the function updates the content (DOM) on the page instantly.

10
New cards

What is the Document Object Model (DOM), and what do the terms 'Document', 'Object', and 'Model' stand for?

The DOM is a programming interface created by the browser that represents every HTML element as an object organized in a tree structure. 'Document' refers to the Entire Web Page, 'Object' means Everything becomes an Object, and 'Model' describes the Hierarchical Structure.

11
New cards
<p>In the DOM Tree Structure shown, what represents the Root Node, and what is the parent node of <code>&lt;head&gt;</code> and <code>&lt;body&gt;</code>?</p>

In the DOM Tree Structure shown, what represents the Root Node, and what is the parent node of <head> and <body>?

The Root Node is Document, and the parent node of both <head> and <body> is the <html> element node.

12
New cards

According to the DOM terminology table, which nodes serve as examples of Root Node, Parent Node, Child Node, and Sibling Nodes?

Root Node: Document Parent Node: body Child Node: input Sibling Nodes: h1, input, button

13
New cards

What is the functional difference between querySelector() and querySelectorAll()?

querySelector() finds the first matching CSS selector, while querySelectorAll() finds all matching CSS selectors.

14
New cards

In the DOM method syntax document.getElementById("name"), what is the meaning of each constituent part?

document: Current webpage .: Access operator get: Retrieve Element: HTML element By: Using Id: Unique identifier ("name"): ID to search

15
New cards
<p>Based on the array diagram, which element is retrieved at index $$2$$, and what is the index of element <code>"ABC"</code>?</p>

Based on the array diagram, which element is retrieved at index 22, and what is the index of element "ABC"?

Element "John" is located at index 22, and "ABC" is located at index 00.

16
New cards

What are the specific purposes of the array operations length, push(), pop(), shift(), and unshift()?

length: Find number of elements push(): Add a new element pop(): Remove last element shift(): Remove first element unshift(): Add element at beginning

17
New cards

What are the roles and examples of JavaScript's built-in objects: Math, Date, String, Number, and Array?

Math: Mathematical calculations (e.g., random numbers, square root) Date: Date and Time (e.g., current date) String: Text operations (e.g., uppercase, lowercase) Number: Numeric operations (e.g., convert text to numbers) Array: Collection handling (e.g., store multiple values)

18
New cards

What is a Regular Expression (Regex)?

A Regular Expression (Regex) is a sequence of characters used to define a search pattern for matching, validating, or searching text.

19
New cards

In Regular Expressions, what do the symbols ^, $, [A-Z], [a-z], [0-9], +, and * denote?

^: Start of text (Starts with) $: End of text (Ends with) [A-Z]: Uppercase letter [a-z]: Lowercase letter [0-9]: Digit +: One or more (At least one) *: Zero or more (Optional repetitions)

20
New cards

What is the step-by-step registration form validation workflow using DOM and Regex?

Student Enters Data → DOM Reads Input → Regex Checks Format → Valid? → YES: Store Data; NO: Display Error.