Input validation

From Higher Computing Science
Jump to: navigation, search

Key points

  • Input validation is an algorithm that asks the user for data within a particular range, and repeats the question until data in the correct range is entered.

Information

Haggis implementation

RECEIVE num FROM (INTEGER) KEYBOARD
WHILE num<0 OR num>100 DO
    SEND "Number out of range. Enter number between 1 and 100" TO DISPLAY
    RECEIVE num FROM (INTEGER) KEYBOARD
END WHILE

Python implementation

Videos

Further information

Test yourself

Teaching resources