HTML and CSS Reference
In-Depth Information
Extend Your Knowledge continued
3. Write a user-defined function, disableItems(), which will be called by an onload event handler, to
disable the e-mail text box, the submitreg button, the emailfield, and the PassMark image. This
function should also make sure the acceptpolicy and rejectpolicy radio buttons are enabled.
4. Write a user-defined function, named accept_it(), that is called when the acceptpolicy option button
is clicked. This function should enable the emailfield and the register (submitreg) button.
5. Write a user-defined function, called register(), that validates the e-mail address entered into the
emailfield. If the e-mail address is not in the proper form with an @ sign, display the following
error message: “Sorry, that e-mail address is not in a valid format. Please re-enter your e-mail
address.” Place focus back on the emailfield. If the e-mail address is in the correct format, display
the message:” Your registration has been submitted,” and then display the PassMark image
6. Enter the appropriate event handler in the <body> tag to call the disableItems() function when
the Web page is loaded.
7. Enter the appropriate event handler in the <input> tag acceptpolicy option button to call the
accept_it() user-defined function when the user clicks the acceptpolicy option button.
8. Enter the appropriate event handler in the <input> tag submitreg button to call the register()
user-defined function to validate the e-mail address and display the PassMark image.
9. Save the completed HTML file and test it using your browser. If an error occurs, check your code
from Steps 2 through 8 and save and test again.
10. Validate using the validation Web page.
11. Submit the completed HTML file and Web page in the format specified by your instructor.
Make It Right
Analyze the JavaScript code on a Web page and correct all errors.
Correcting Syntax Errors and Inserting Missing Code
Instructions: Start your browser. Open the file make10-1.html from the Chapter10\MakeItRight
folder of the Data Files for Students. See the inside back cover of this topic for instructions for
downloading the Data Files for Students, or contact your instructor for information about accessing
the required files.
The make10-1.html Web page is a college Web page that allows students to calculate semester
expenses, which contains four errors. Not all errors are necessarily typos or syntax errors. Some are
logic errors, which means a statement may be executed out of order, is missing, or, in the case of
JavaScript, is using an incorrect property or method.
Use the following information as background for your corrections. The number of credit hours
to select from the drop-down menu is 14, and enter 1800 for the total expenses. The corrected Web
page is shown in Figure 10-43.
Perform the following tasks:
1. Refresh the Web page in the browser and look at the error messages. ( Hint: You may have to enable
Internet Explorer script debugging to see the errors. Use the Internet options command on the
Tools menu, click the Advanced tab, and then in the Settings box, Browsing category, deselect the
'Disable script debugging (Internet Explorer)' check box.)
Search WWH ::

Custom Search