JavaScript The Web Warrior Series 6th Edition Vodnik Solutions Manual download
JavaScript The Web Warrior Series 6th Edition Vodnik Solutions Manual download
https://testbankdeal.com/product/javascript-the-web-warrior-
series-6th-edition-vodnik-solutions-manual/
https://testbankdeal.com/product/javascript-the-web-warrior-
series-6th-edition-vodnik-test-bank/
testbankdeal.com
https://testbankdeal.com/product/principles-of-web-design-the-web-
warrior-series-6th-edition-sklar-solutions-manual/
testbankdeal.com
https://testbankdeal.com/product/principles-of-web-design-the-web-
technologies-series-5th-edition-skalar-test-bank/
testbankdeal.com
https://testbankdeal.com/product/materials-science-and-engineering-an-
introduction-9th-edition-callister-solutions-manual/
testbankdeal.com
Principles of Macroeconomics 6th Edition Frank Test Bank
https://testbankdeal.com/product/principles-of-macroeconomics-6th-
edition-frank-test-bank/
testbankdeal.com
https://testbankdeal.com/product/m-management-5th-edition-bateman-
solutions-manual/
testbankdeal.com
https://testbankdeal.com/product/people-and-a-nation-volume-i-
to-1877-9th-edition-norton-test-bank/
testbankdeal.com
https://testbankdeal.com/product/topical-approach-to-lifespan-
development-7th-edition-santrock-test-bank/
testbankdeal.com
https://testbankdeal.com/product/single-variable-calculus-early-
transcendentals-7th-edition-stewart-test-bank/
testbankdeal.com
Object-Oriented Approach to Programming Logic and Design
4th Edition Joyce Farrell Solutions Manual
https://testbankdeal.com/product/object-oriented-approach-to-
programming-logic-and-design-4th-edition-joyce-farrell-solutions-
manual/
testbankdeal.com
JavaScript, Sixth Edition 6-1
Chapter 6
We have designed this Instructor’s Manual to supplement and enhance your teaching
experience through classroom activities and a cohesive chapter summary.
This document is organized chronologically, using the same headings that you see in the
textbook. Under the headings you will find: lecture notes that summarize the section, Teacher
Tips, Class Discussion Topics, and Additional Projects and Resources. Pay special attention to
teaching tips and activities geared towards quizzing your students and enhancing their critical
thinking skills.
In addition to this Instructor’s Manual, our Instructor’s Resources also contain PowerPoint
Presentations, Test Banks, and other supplements to aid in your teaching experience.
At a Glance
• Objectives
• Teaching Tips
• Quick Quizzes
• Additional Projects
• Additional Resources
• Key Terms
© 2015 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a
license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
JavaScript, Sixth Edition 6-2
Lecture Notes
Overview
Forms are one of the most common web page elements used with JavaScript. Chapter 6
explains how to use JavaScript to make web forms easier for users to complete. Students
will learn about form elements and objects. Students will learn about basic form validation,
and implement custom form validation.
Objectives
After completing this chapter, students will be able to:
• Enhance form usability with JavaScript
• Customize browser-based HTML validation
• Implement custom validation to check for errors and display error messages
Teaching Tips
Using JavaScript with Forms
1. Explain that JavaScript is commonly used with forms for two reasons:
• To make forms easier for users to fill out
• To validate or process user-entered data before the data is submitted to a server-
side script
2. Introduce the concept of validation, the process of checking user-entered data to ensure
it conforms to the proper rules and format. Give examples of the types of validation
typically found on a customer form to order merchandise from a website.
3. Explain that a form object represents a form element in an HTML document. Use
Tables 6-1 through 6-3 to present the properties, events, and methods of form objects.
4. Mention that the elements used for collecting data in a form include input, select,
option, textarea, and button. Review Tables 6-4 through 6-6 with students,
which show properties, events, and methods common to most or all of these elements.
2. Introduce the document. syntax shown on Pages 366-367 and the forms array.
© 2015 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a
license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
JavaScript, Sixth Edition 6-3
3. Note that using Document object methods makes your code more flexible when you
need the same code to be able to refer to both form and non-form elements.
4. Allow students time to complete the steps on Page 367 to open and view the order form.
1. Mention that one of the most important form-related roles is validating user input. Note
that there are a few steps a programmer can take to reduce the amount of validation
necessary.
1. Explain that most form validation consists of checking data typed into input and
textarea boxes for accuracy. Give an example, using Figure 6-2.
2. Mention that a programmer can use other types of form fields to limit users’ choices.
Review some of the alternative form elements using Table 6-7.
3. Give an example of improving the design shown in Figure 6-2 with the alternative in
Figure 6-3.
1. Define assistive functions, which prevent users from entering erroneous data in the first
place.
2. Give the example of an order form for flowers, for which setting a default delivery data
may result in incorrect delivery. Note that a solution for this situation is to set the
selectedIndex property of a select object to -1, which corresponds to no
selection.
4. Allow students time to complete the exercise on Pages 372-374 to change the
selectedIndex property for select elements.
© 2015 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a
license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
JavaScript, Sixth Edition 6-4
Quick Quiz 1
1. Many websites use ____ to collect information from users and transmit that information
to a server for processing.
Answer: forms
2. The ____ element designates a form within a web page and contains all the text and
elements that make up a form.
Answer: form
3. Any form element into which a user can enter data (such as a text box) is called a(n)
____.
Answer: field
4. To use JavaScript to access form controls and verify form information, you use the
____ object, which represents a form on a web page.
Answer: Form
5. Programming constructs that prevent users from entering erroneous data in the first
place are called ____.
Answer: assistive functions
1. Explain that a programmer can add and remove option elements in a select
element.
2. Note that a programmer can also set properties of option elements. Review Table 6-9
for properties of option elements.
3. Mention that a common use of adding and removing options from a select element is
to change the options shown in a list based on another selection a user has made in the
same form. Give the example of changing the number of days available in a selection
list based on the selected month.
4. Allow students time to complete the exercise on Pages 376-381 to program the days list
to change dynamically based on the selected month and year.
© 2015 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a
license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
JavaScript, Sixth Edition 6-5
1. Explain that many older browsers do not support the usability enhancements to HTML.
Note that JavaScript can simulate the behavior of these features in older browsers.
2. Mention that a popular recent feature in form creation is the placeholder attribute
of the input and textarea elements.
3. Note that a programmer can specify a word or phrase as the value of the
placeholder attribute, which is then displayed in the input or textarea box,
generally in gray rather than black characters.
4. Explain that the placeholder attribute provides guidance on what the user should
enter, as well as any formatting constraints.
5. Allow students time to complete the three exercises on Pages 382-388 to add
placeholder text to the Custom message box in older browsers.
1. Give the example of a form which has a “Custom message” checkbox a user can check
to send a message which is entered into a textarea element. Explain that if there is
an inconsistency between the two, it may not be treated properly by back-end code.
2. Explain that a solution is to add a function that checks a user’s entry in the textarea
field and checks the “Custom message” box for them if they have entered custom text.
3. Review Tables 6-10 and 6-11 for properties and methods of textarea elements.
4. Allow students time to complete the exercise on Pages 389-390 to create a function to
automatically check the Custom message check box when a custom message has been
entered.
1. Explain that JavaScript is commonly used to improve form usability by copying data
entered in one field to another field that a user indicates should contain the same data.
Give the example of billing and shipping addresses in a purchasing application.
2. Allow students time to complete the exercise on Pages 391-393 to enable users to use
billing address information for the shipping address.
© 2015 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a
license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
JavaScript, Sixth Edition 6-6
1. Explain that historically, JavaScript code was written to perform common and important
validation tasks. Note that in recent years, many browsers themselves often perform
validation without extra JavaScript code. This type of validation is called browser-based
validation, native validation, or HTML5 validation.
1. Review the attributes in Table 6-12, which are used to specify browser-based validation.
2. Describe additional browser-based validation linked to values for the type attribute,
presented in Table 6-13.
3. Allow students time to complete the exercise on Pages 395-397 to see how browser-
based validation deals with missing or invalid data in the order form.
1. Define constraint validation API, and explain that many aspects of the way browsers
present browser-based validation feedback are customizable through its properties and
methods.
3. Discuss the methods of the constraint validation API, as presented in Table 6-15.
4. Describe that in conjunction with these properties and methods, you can use the CSS
:invalid and :valid pseudo-classes to change the properties of form elements based on
their validity status.
5. Work through the example code on Page 399, and show the result of the code, using
Figure 6-13.
6. Note that some features of browser-based validation are missing, which makes it
difficult to use in complex situations.
7. Allow students time to complete the exercise on Pages 401-402 to disable browser-
based validation for the order form.
2. Allow students time to complete the exercise on Pages 404-408 to create the main
validation function.
1. Explain that creating a function to validate required fields generally involves retrieving
the values of the required fields and checking to see whether the value of any of them is
an empty string. Review the general form of the syntax, given on Page 408.
1. Mention that a programmer uses different properties to validate each form element and
input type. Note that for text boxes, a programmer can use the value property to check
for a value.
2. Review both Table 6-16 and Table 6-17, which contain the properties and methods of
the input element.
4. Allow students time to complete the exercise on Pages 410-413 to create a custom
validation function for input fields in the Billing Address fieldset.
1. Introduce the State field and review its syntax, using the code on Page 414.
2. Allow students time to complete the exercises on Pages 414-417 to add validation for
the State selection lists to the validation function for the address and delivery date
fieldsets.
1. Mention that to check whether an option button has been selected, you access the value
of its checked property.
3. Allow students time to complete the exercise on Pages 418-421 to create a validation
function for the Payment fieldset.
© 2015 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a
license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
JavaScript, Sixth Edition 6-8
1. Explain that a programmer may need to create functions to test logic specific to the
form. Give the example of a set of option buttons including “other”, followed by a text
box. Note that validation code could include the text box only when “other” is selected.
1. Go through the example given at the bottom of Page 421, which addresses the Message
fieldset. Note that if the Custom message box is checked, a programmer’s code should
verify the text in the textarea control.
2. Allow students time to complete the exercise on Pages 422-424 to create a validation
function for the Custom message checkbox and its dependent textarea control.
1. Explain that in the Snoot Flowers order form, some fields need not be completed,
because buyers are not required to create an account. Note, however, that if a user
makes an entry in one of the fields, all three must be completed.
3. Allow students time to complete the exercise on Pages 425-428 to create a validation
function for the Create Account fieldset.
1. Explain that a programmer can use JavaScript’s built-in isNaN() function for fields
that require numeric values to determine whether the user actually entered a number.
Show the syntax of the function, given on Page 429.
2. Allow students time to complete the exercise on Pages 429-432 to validate the Card
Number and CVV numeric fields.
Quick Quiz 2
1. The JavaScript ____ function can be used to determine if the value entered by a user is
numeric.
© 2015 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a
license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
JavaScript, Sixth Edition 6-9
Answer: isNaN()
2. You can use the ____ property to determine whether an individual check box has been
selected.
Answer: checked
3. The ____ property can be used to determine if a text box has a value.
Answer: value
4. True or False: Browser-based validation can replace the need to write custom JavaScript
code to validate user input.
Answer: True
5. The ____ attribute is used to provide guidance on what the user should enter, and any
formatting constraints that apply.
Answer: placeholder
2. Why is the <input> element the most commonly used form element?
Additional Projects
1. Use JavaScript to create a web page that allows clients to order pizza. Clients should be
able to select toppings, type of crust, and method of payment. Validate that the form is
correct before submitting it.
2. Use JavaScript to create a web page for a shuttle company. The client should be able to
reserve a ticket using this page, selecting the date and time, pick-up and destination
locations, and the method of payment from a list of available options. Your code should
validate the form before it is submitted.
© 2015 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a
license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
JavaScript, Sixth Edition 6-10
Additional Resources
1. JavaScript Form Object:
www.comptechdoc.org/independent/web/cgi/javamanual/javaform.html
2. Form Object:
www.javascriptkit.com/jsref/form.shtml
4. Form Validation:
www.yourhtmlsource.com/javascript/formvalidation.html
Key Terms
assistive functions—JavaScript functions that reduce the likelihood of user errors when
completing a form by preventing users from entering erroneous data in the first place
browser-based validation—Validation tasks performed by browsers themselves
without any extra JavaScript, enabled by recent enhancements to HTML and to modern
browsers; also known as native validation
constraint validation API—The set of properties and methods that enables developers
to customize aspects of the way browsers present browser-based validation feedback
createDocumentFragment() method—The method of the Document object that
creates an empty document fragment
friction—A loose measure of the persistence required for a website user to accomplish
a goal, such as placing an order
HTML5 validation—See browser-based validation
native validation—See browser-based validation
submit event—The event that fires when a form is submitted, which is generally when
a submit button is selected on a form
validation—The process of checking that information provided by users conforms to
rules to ensure that it appropriately answers the form’s questions and is provided in a
format that the site’s back-end programs can work with
© 2015 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a
license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Another Random Scribd Document
with Unrelated Content
Apud alios.—I, 210.—Cicéron, Tusc., V, 36.
Ἀριστα χωλός*.—III, 542.—Théocrite, Idylle, IV, 62.
Ἀριστον μέτρον*.—III, 674.—Diogène Laerce, I, 93.
Aristoni tragico.—I, 288.—Tite-Live, XXIV, 24.
Arma acri.—III, 224.—Virgile, En., VIII, 441.
Arma enim.—II, 56.—Cicéron, Tusc., II, 16.
Arma proferri.—I, 532.—César, de Bello gall., VII, 11.
Arma rogo.—III, 224.—Virgile, En., VIII, 383.
Armati terram.—III, 396.—Virgile, Enéid., VII, 748.
Arripe dilatam.—II, 556.—Prudence, Cont. Symm., II, 643.
Ἀσώτους ex.—I, 218.—Cicéron, de Nat. deor., III, 31.
At tibi nil.—I, 548.—Martial, Epigr., II, 58, 11.
At tu Catulle.—III, 466.—Catulle, Carm., VIII, 19.
Athenis tenue*.—II, 366.—Cicéron, de Fato, 4.
Atque adeo.—II, 128.—Manilius, IV, 907.
Atque aliquis.—III, 222.—Ovide, Métam., IV. 187.
Atque idem.—I, 54.—Virgile, En., X, 732.
Atque illum.—II, 222.—Cicéron, trad. du Timée, 2.
Atque in se.—I, 128.—Virgile, Georg., II, 402.
Attonitus novitate.—II, 370.—Ovide, Métam., XI, 128.
Audit iter.—I, 112.—Claudien, in Ruf., II, 137.
Auferimur.—II, 400.—Ovide, de Rem. Amor., I, 343.
Auro quoque*.—III, 304.—Calpurnius, Eclog., VII, 53.
Aut bibat.—II, 218.—Cicéron, Tusc., V, 4.
Aut fuit*.—I, 452.—La Boétie.—Ovide, Ep. d’Ariadne.
Aut nimiis.—III, 382.—Lucrèce, V, 216.
Aut qui non.—I, 276.—Quintil., VIII, 3.
Aut verberatæ.—III, 383.—Horace, Od., III, 1, 29.
Aves quasdam.—I, 72.—Cicéron, de Nat. deor., II, 64.
Avida est.—I, 454.—Sénèque, de Prov., 4.
Ayme l’estat.—III, 398.—De Pibracq, Quatrains.
B
E cosi.—I, 406.—Pétrarque.
Ἡ δεισιδαιμονια*.—II, 222.—Stobée, Serm., XXII, 189.
Ἐ ζῆν*.—I, 380.—D’après Stobée, Serm., 20.
Ea non.—III, 84.—Tite-Live, XXXII, 21.
Eam vir.—I, 46.—Florus, I, 12.
Ego deum.—II, 256.—Ennius, ap. Cic., de Div., II, 50.
Ego hoc.—II, 452.—Cicéron, de Fin., II, 15.
Ego illos.—III, 476.—Sénèque, Epist. 64.
Ego vero*.—II, 76.—Cicéron, de Senect., 10.
Egregium.—III, 470.—Juvénal, XIII, 64.
Eheu! cicatricum.—III, 402.—Horace, Od., I, 35, 33.
Ejulatu*.—III, 28.—Cicéron, Tusc., II, 14.
E’l silenzio.—II, 140.—Le Tasse, Aminta, II, 34.
Emori*.—II, 426.—Cicéron, Tusc., I, 8.
Emunctæ.—I, 274.—Hor., Sat., I, 4, 8.
Ἐν τῷ.—II, 218.—Sophocle, Ajax, 552.
Enimvero*.—III, 404.—Plaute, Prologue des Captifs.
Ense maritali.—III, 222.—Source inconnue.
Eodem enim.—III, 692.—Cicéron, Tusc., IV, 31.
Ἐπέων δὲ.—I, 518.—Homère, Iliade, XX, 249.
Equi sine.—I, 538.—Tite-Live, XXXV, 11.
Equidem.—III, 374.—Quinte-Curce, IX, 1.
Eritis.—II, 204.—Homère, ap. Cic., de Fin., V, 18.
Esse unum.—III, 270.—Q. Cicéron, de Petit. consul., 14.
Esse videatur.—II, 76.—Cicéron, de Orat., 23.
Est prudentis.—III, 418.—Cicéron, de Amic., 17.
Est quædam flere.—II, 538.—Ovide, Trist., IV, 3, 27.
Est quædam vox.—III, 646.—Quintilien, XI, 3.
Est situm.—II, 216.—Cicéron, de Fin., I, 17.
Estne.—I, 406.—Catulle, LXVI, 15.
Et cantharus.—III, 394.—Horace, Epist., I, 5, 23.
Et casta.—II, 266.—Lucrèce, I, 99.
Et cuncta.—I, 404.—Horace, Od., II, 1, 23.
Et errat.—II, 26.—Térence, Adelph., I, 1, 40.
Et fugit.—II, 434.—Virgile, Eglog., III, 65.
Et gens.—I, 538.—Lucain, IV, 682.
Et habet.—III, 186.—Martial, VII, 58, 9.
Et ii, qui.—II, 86.—Cicéron, Epist. fam., XV, 19.
Et invictum.—I, 404.—Manilius, Astr., IV, 87.
Et ipse.—I, 300.—Horace, Od., II, 2, 6.
Et languor.—II, 432.—Horace, Epod., XI, 9.
Et laxas.—II, 522.—Catulle, XCIV, 8.
Et lupus.—II, 570.—Ovide, Trist., III, 5, 35.
Et male.—I, 528.—Manilius, IV, 95.
Et mentem.—III, 210.—Virgile, Georg., III, 267.
Et mihi.—III, 200.—Pseudo-Gallus, I, 61.
Et militavi.—III, 642.—Horace, Od., III, 26, 2.
Et minimæ.—III, 184.—Ovide, Trist., III, 11, 22.
Et mutæ.—II, 138.—Lucrèce, V, 1058.
Et nihil.—II, 262.—Lucrèce, III, 857.
Et nudam.—III, 254.—Ovide, Amor., I, 5, 24.
Et nulla.—III, 104.—Ovide, de Ponto, I, 7, 37.
Et Numidæ.—I, 538.—Virgile, En., IV, 41.
Et obscenas.—II, 380.—Cicéron, Tusc., IV, 33.
Et patimur.—II, 554.—Juvénal, VI, 291.
Et plaga.—II, 366.—Végèce, I, 2.
Et post.—I, 412.—Horace, Od., III, 1, 40.
Et quærendum.—III, 266.—Catulle, Carm., LXVII, 27.
Et quo ferre.—I, 534.—Lucain, VIII, 384.
Et quo quemque.—I, 254.—Virgile, En., III, 459.
Et se n’aflige.—(III, 26).—Auteur inconnu. (Ne se trouve que dans
les éd. ant. à 1595).
Et secum.—II, 616.—Claudien, in Eutrop., I, 237.
Et solem*.—II, 404.—Virgile, Enéide, IV, 470.
Et sua sunt*.—III, 406.—Source inconnue.
Et supera*.—III, 304.—Lucrèce, V, 327.
Et taciti.—III, 268.—Ovide, Amor., I, 7, 21.
Et tellus.—II, 146.—Lucrèce, II, 1157.
Et velut.—III, 16.—Virgile, Enéid., XII, 521.
Et veniunt.—I, 360.—Properce, I, 2, 10.
Et via.—I, 26.—Virgile, En., XI, 151.
Et versus.—III, 194.—Juvénal, VI, 196.
Et vulgo.—II, 408.—Lucrèce, IV, 73.
Etenim.—III, 510.—Cicéron, Tusc., IV, 18.
Etiam.—I, 662.—Sentences de Publius Syrus.
Εῦλογον*.—I, 636.—Diogène Laerce, VIII, 130.
Ex quo Ennius.—I, 212.—Cicéron, de Off., III, 45.
Ex quo intelligitur.—I, 462.—Cicéron, Tusc., III, 28.
Ex senatus-consultis.—III, 92.—Sénèque, Epist. 95.
Excindintur*.—III, 516.—Source inconnue.
Excludat.—III, 434.—Horace, Ep., II, 1, 38 et 45.
Excursusque.—II, 70.—Virgile, Georg., IV, 194.
Excutienda.—III, 444.—Cicéron, de Amic., 6. (Se trouve une
seconde fois dans l’éd. de 88, II, 60).
Exeat aula.—III, 464.—Lucain, VIII, 493.
Exeat inquit.—III, 302.—Juvénal, Sat., III, 153.
Experta.—III, 266.—Martial, VII, 58, 3.
Exsilia tormenta.—III, 572.—Sénèque, Epist., 91, 107.
Exsilioque.—III, 254.—Virgile, Georg., II, 511.
Exstantesque.—II, 398.—Lucrèce, IV, 398, 390, 421.
Exsuperat.—III, 554.—Virgile, Enéid., XII, 46.
Extrema.—II, 666.—Virgile, Georg., II, 473.
G
Galla nega.—II, 432.—Martial, IV, 37.
Gaudeat.—II, 346.—Dicton judiciaire.
Gentes esse.—II, 376.—Ovide, Métam., X, 331.
Gigni pariter.—II, 318.—Lucrèce, III, 446.
Gloria in.—II, 442.—S. Luc, Evang., II, 14.
Gloria nostra.—II, 450.—S. Paul, Ep. ad Corinth., II, 1, 12.
Gloria, quantalibet.—II, 442.—Juvénal, Sat., VII, 81.
Gratatusque.—I, 548.—Ovide, de Ponto, IV, 9, 13.
Gratum est.—II, 608.—Juvénal, XIV, 70.
Gravissimi.—I, 520.—Porcius Latro.