Input validation
Checking that data a user enters is the expected type, length and format before the program uses it, so bad or harmful input is rejected.
Understanding Input validation in ACARA Digital Technologies Years 9–10
What it does: This combines a length check and a type check so only the expected format is accepted, which is input validation. Checking for risky characters such as quotes and angle brackets rejects harmful input before the program uses it, which helps stop SQL injection and XSS. Age should be a number, so text fails the type check and must be rejected. len() measures how many characters were entered. isdigit() checks the type of characters instead. Allowing only known good input (an allow list) is safer because attackers can disguise bad input. The first has symbols and script tags, so it fails the format check and could be harmful. The second matches the format.
Common mistakes: This line runs when the input passes the isdigit() check, so it is valid. The message should say the age is valid, for example print("Valid age"). A length check should accept names up to the limit. With >= it only accepts long names and rejects short ones. It should be <= 20.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 782–809) and word search (Modules 743–809).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
input validationFill in the Blanks
Spot the Error
Student with a class code? Join your class →