{"base":{"id":"cs8-26","subject":"Data","title":"Validation and forms","scene":"data","steps":[{"mode":"range","eyebrow":"Range check","title":"Between the limits","body":"Validation checks each entry against a rule when it is typed, before it is saved. A range check only accepts values between limits: here, ages 8 to 16. Change the age.","controls":[{"id":"age","label":"Age typed in","min":0,"max":30,"step":1,"value":12}]},{"mode":"length","eyebrow":"Length check","title":"Not too short, not too long","body":"A length check counts the characters. Usernames here must be 4 to 12 characters. Try each username.","actions":[{"id":"u0","label":"Al"},{"id":"u1","label":"MiaChen"},{"id":"u2","label":"SuperLongUsername99"}]},{"mode":"email","eyebrow":"Presence and format","title":"Not blank, right pattern","body":"A presence check stops a field being left empty. A format check makes sure data follows a pattern, like name@place.domain for an email. Try each entry.","actions":[{"id":"e0","label":"(blank)"},{"id":"e1","label":"mia@school.org"},{"id":"e2","label":"mia.school.org"},{"id":"e3","label":"mia@"}]},{"mode":"form","eyebrow":"Form design","title":"Help people enter good data","body":"A good form has clear labels, hints and the right controls, such as drop-down lists and date pickers, so mistakes are less likely. Compare the two forms.","actions":[{"id":"good","label":"Show the clear form"}]},{"mode":"quiz","eyebrow":"Check yourself","title":"Which check?","body":"A form must reject a test score of 130 when scores can only be 0 to 100.","question":"Which validation check does this?","options":["Presence check","Range check","Length check"],"answer":1,"right":"Correct. The value is outside the allowed limits.","wrong":"Not quite. Is the problem the value, the blank or the length?","look":"range"}],"more":[{"type":"cards","id":"ideas","eyebrow":"Popular idea vs science","title":"Common mix-ups","items":[{"tag":"Popular idea","title":"\"Validation makes sure data is true.\"","body":"It only checks data is sensible. A 12-year-old typing 13 still passes a range check."},{"tag":"Popular idea","title":"\"Free text boxes are best for every field.\"","body":"Drop-down lists and date pickers stop typing mistakes before they happen."},{"tag":"Popular idea","title":"\"An error message just needs to say 'Error'.\"","body":"Good messages say what is wrong and how to fix it."}]},{"type":"cards","id":"checks","eyebrow":"Validation checks","title":"Five common checks","items":[{"tag":"Presence","title":"Not empty","body":"A required field can't be blank."},{"tag":"Range","title":"Between limits","body":"Age 8 to 16."},{"tag":"Length","title":"Number of characters","body":"Username 4 to 12 characters."},{"tag":"Format","title":"A pattern","body":"Email: name@place.domain."},{"tag":"Type","title":"Right kind of data","body":"A number field rejects 'ten'."}]},{"type":"cards","id":"verify","eyebrow":"Not the same","title":"Validation and verification","items":[{"tag":"Validation","title":"Is it sensible?","body":"Automatic rules check the data is reasonable."},{"tag":"Verification","title":"Was it typed correctly?","body":"E.g. typing a password twice, or checking against the original form."}]},{"type":"activities","id":"try","eyebrow":"Try it at home","title":"Form critic","items":[{"title":"Improve a real form","time":"15 minutes","need":["A paper form (a library card, competition entry or school form)","A pen"],"steps":["Find each field on the form and write which validation check would suit it.","Circle any field where people might write data in different ways (dates, phone numbers).","Suggest a better control for it: tick boxes, a list of choices or boxes for each digit.","Redesign one section of the form."],"why":"Clear forms and validation together give clean, consistent data.","safety":"No safety risks."}]},{"type":"quiz","id":"quiz","eyebrow":"Quiz","title":"Six more questions","questions":[{"question":"When does validation happen?","options":["When data is entered, before it is saved","Once a year","Only when the computer restarts"],"answer":0,"right":"Correct. It checks entries straight away.","wrong":"Not quite. When is bad data easiest to stop?"},{"question":"Which check rejects a blank email box?","options":["Range check","Format check","Presence check"],"answer":2,"right":"Correct. Presence means 'must be filled in'.","wrong":"Not quite. The field is empty."},{"question":"A password must be at least 8 characters. Which check is this?","options":["Length check","Range check","Type check"],"answer":0,"right":"Correct. It counts characters.","wrong":"Not quite. What is being counted?"},{"question":"Which entry passes an email format check?","options":["leo@mail.com","leo.mail.com","leo@"],"answer":0,"right":"Correct. It has name@place.domain.","wrong":"Not quite. Look for the @ and the domain."},{"question":"Why use a drop-down list for ticket type?","options":["It looks old-fashioned","People can only choose a valid option","It makes typing slower"],"answer":1,"right":"Correct. It prevents spelling mistakes.","wrong":"Not quite. What can't go wrong with a list?"},{"question":"A user types age 14 but is really 13. Validation…","options":["always catches it","deletes the record","accepts it, because 14 is sensible"],"answer":2,"right":"Correct. Validation checks it's reasonable, not true.","wrong":"Not quite. Is 14 inside the range?"}]},{"type":"checklist","id":"check","eyebrow":"Self-check","title":"I can explain…","items":["what validation is and when it happens","presence, range, length, format and type checks","the difference between validation and verification","how labels, hints and controls make a good form"]},{"type":"keywords","id":"words","eyebrow":"Key words","title":"Words to know","items":[{"word":"validation","meaning":"Automatic checks that entered data is sensible."},{"word":"presence check","meaning":"Makes sure a field isn't left empty."},{"word":"range check","meaning":"Makes sure a value is between limits."},{"word":"length check","meaning":"Checks the number of characters."},{"word":"format check","meaning":"Checks data follows a pattern."},{"word":"verification","meaning":"Checking data was entered correctly."}]},{"type":"sources","id":"sources","title":"Sources","items":["BBC Bitesize GCSE Computer Science: Validation and verification"]}]},"overlay":null}