Unit summary
- JavaScript changes the look of a page with the style property and, better, with classList.
- Form validation checks data on submit and calls preventDefault when a rule fails.
- Regular expressions describe the shape of text, and ^ and $ make the whole text match.
- AJAX updates part of a page from the server in the background.
- XMLHttpRequest uses readyState 4 and status 200 to show that a reply is ready.
- JSON holds data as quoted keys and typed values, and parse and stringify convert it.
- The Fetch API uses promises, and response.ok must be checked.
- XML uses custom tags, a DTD or schema decides validity and XSLT transforms XML.
- Interactive components combine HTML parts, CSS states and a JavaScript class toggle.
Glossary
| Term | Meaning |
|---|---|
| Accordion | A set of headings where selecting one opens or closes its panel of content. |
| AJAX | A technique for sending and receiving data from a server in the background, without reloading the page. |
| Asynchronous request | A request that lets the page keep working while it waits for the reply. |
| classList | An element property with methods add, remove and toggle for changing its CSS classes. |
| Dark mode | A colour scheme with light text on a dark background, often switched on by a button. |
| Fetch API | A modern browser interface that requests data from a server and returns a promise. |
| Form validation | Checking that the data a user enters is complete and in the correct form. |
| JSON | JavaScript Object Notation, a text format that stores data as keys and values. |
| Key-value pair | A name in double quotes, a colon and a value, which is one item of a JSON object. |
| Password strength | A measure of how hard a password is to guess, judged by its length and variety of characters. |
| preventDefault | An event method that stops the browser's normal action, such as sending a form. |
| Promise | An object that stands for a result that will arrive later, as a success or a failure. |
| Quantifier | A symbol such as +, * or {n} that says how many times a pattern part may repeat. |
| readyState | A number from 0 to 4 that shows how far an XMLHttpRequest has progressed. |
| Regular expression | A pattern written between slashes that describes the form that text must take. |
| Well-formed XML | XML that follows the basic syntax rules, such as one root element and closed tags. |
| XML | Extensible Markup Language, a format that uses custom tags to carry data. |
| XMLHttpRequest | A built-in browser object used to send an HTTP request and receive the reply. |
Question bank
Short Answer Questions (2 marks each)
- What is the difference between the style property and classList?
- What does classList.toggle do?
- What is form validation? Why is server-side checking also needed?
- What does preventDefault do?
- What is a regular expression? Give one example.
- What do the symbols ^ and $ mean in a pattern?
- What is AJAX? State one advantage.
- Name the five values of readyState.
- What is JSON? Write a small JSON object.
- What is the difference between well-formed and valid XML?
Medium Answer Questions (5 marks each)
- Explain how classList and the style property are used to change CSS from JavaScript.
- Explain client-side form validation with required and length checks.
- Explain regular expressions with patterns for email, phone number and password.
- Explain advantages and disadvantages of AJAX.
- Explain XMLHttpRequest with readyState and status codes.
- Explain DTD, XML Schema, XSLT and XHTML.
Long Answer Questions (15 marks each)
- Design a registration form with name, email, password and confirm password. Write the complete JavaScript validation using regular expressions and explain it.
- Explain AJAX and XMLHttpRequest in detail. Write a program that loads a text file asynchronously and handles the status codes.
- Explain JSON syntax, JSON.parse and JSON.stringify and the Fetch API. Write a program that fetches student records and shows them in an HTML table.
- Explain how HTML, CSS and JavaScript combine to build an accordion, a modal and a slider, with code for one of them.
Sources
- Official BCA syllabus (NEP 2025 scheme), Web Application Development, course code 25BCA405DS04, Unit IV
