JavaScript – OCR A Level Computer Science lesson (H446)
Students learn to write JavaScript that validates a form field in the browser and changes the page with getElementById and innerHTML.
Lesson 9 of 13 in unit 12.9 Networks and Web Technologies, taught in Year 12, Summer 1. It answers one big question: How can a web page check input before sending it?
By the end, students can write JavaScript that validates a form field in the browser and changes the page with getElementById and innerHTML.
- The Build (the main task)
- Write a JavaScript function for Lumen Row's booking form that checks the number of tickets is between 1 and 10 and shows a message on the page using getElementById and innerHTML (6 marks).
- Support version
- The HTML form and an empty function given; the if statement as a Parsons problem with the OCR pseudocode version beside it.
- Challenge
- Extend the check so the email field must contain an @ followed later by a full stop, and explain why the server must check it again.
- Real-world link
- Lumen Row's booking form, before it is sent to the server.
- Key words
- JavaScript, Validation and Interactive, each with a definition, an icon and a common mix-up on the key vocabulary slide.
- Misconceptions it tackles
- “JavaScript validation runs on the server”; “Validation makes sure the data is correct”.
- OCR H446 specification
- 1.3.4 (a).
Every lesson follows the same Code & Commerce structure: a Bell Task recall starter, key vocabulary with definitions and icons, short teaching chunks with a check before pupils move on, The Build (one main task), challenge questions that get harder, and an exit question. Answers reveal one at a time on the slides, and everything is editable PowerPoint and Word.
Students need computers for the main task.
Also sold in the Networks and Web Technologies unit bundle, which includes the medium term plan, and in the full-year and complete-course bundles.
An independent resource written for OCR A Level Computer Science (H446). It is not endorsed by OCR or Cambridge University Press & Assessment. Programming project (NEA) lessons teach general skills on a made-up example project and give supervised time, within JCQ's rules on the help a centre may give.
What's included
- Slide deck (PowerPoint)
- Lesson plan (Word)
- Worksheet (Word)
- Support worksheet with scaffolds (Word)
- Single-teacher licence: use and adapt it with your own classes
More for A Level Computer Science
See allStudents learn to explain what protocols and standards are and why networks depend on them, saying what a protocol defines.
Free sample lessonStudents learn to describe the four layers of the TCP/IP stack and what each adds as a booking request is sent.
Students learn to describe how DNS resolves a domain name into an IP address and tell IP addresses from MAC addresses.
Written for the specifications named. Not endorsed by or affiliated with any exam board.