Question 5

OCR Computer Science June 2024 Computer principles (H046-01)AS5 marks

On the specification

1.3 Exchanging data2.2 Problem solving and programming
Question text

5 An online shop uses a website to sell its products. Part of the HTML code that is used for a login form on the website is shown here. <p> <label>Username:</label> <input type="text" id="userName"> </p> <p> <label>Password: </label> <input type="text" id="Password" onchange="errorCheck()"> </p> <p> <label id="errorText"> </p> The <label> tag will instruct the user what information they need to enter. The code onchange will run a function called errorCheck automatically after a password has been entered. The function errorCheck will check that the password is a suitable length. Write JavaScript code for the function errorCheck which: • checks the length of the password is between 8 and 12 characters (including 8 and 12) • displays the message “Password Length Error” in the HTML label tag identified by the id errorText if the length is not between 8 and 12 characters. [5]