Deck 6: Enhancing and Validating Forms
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Match between columns
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/41
Play
Full screen (f)
Deck 6: Enhancing and Validating Forms
1
You can use the CSS ____ pseudo-classes to change the properties of form elements based on their validity status.
A) :submit and :reset
B) :hover and :blur
C) :before and :after
D):invalid and :valid
A) :submit and :reset
B) :hover and :blur
C) :before and :after
D):invalid and :valid
D
2
You use the ____ method on an object to block the action normally associated with an event.
A)preventDefault()
B)submit()
C)checkValidity()
D)select()
A)preventDefault()
B)submit()
C)checkValidity()
D)select()
A
3
Many aspects of the way browsers present browser-based validation feedback are customizable through the properties and methods of the ____.
A)Document Object Model
B) DOM tree
C)browser object model
D)constraint validation API
A)Document Object Model
B) DOM tree
C)browser object model
D)constraint validation API
D
4
In general, modern browsers display validation feedback after the ____ event is triggered by a form.
A) submit
B) reset
C) validate
D) check
A) submit
B) reset
C) validate
D) check
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
5
What element property would you use when copying the contents of one text field to another text field?
A) value
B) default
C) content
D) selectedIndex
A) value
B) default
C) content
D) selectedIndex
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
6
Which attribute enhances usability in modern browsers?
A) id
B) src
C) placeholder
D) value
A) id
B) src
C) placeholder
D) value
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
7
To display no default value on a selection list, you set its ____ property to -1.
A) selectedIndex
B) checked
C) selected
D) value
A) selectedIndex
B) checked
C) selected
D) value
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
8
Which attribute toggles off validation of a form when added to the opening
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
9
The ____ event fires when a form is submitted.
A)clear
B)blur
C)input
D)submit
A)clear
B)blur
C)input
D)submit
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
10
Assistive functions perform a type of validation.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
11
Which form element is useful for limiting user options to a set of choices?
A)textarea
B)selection list
C)text input box
D)submit button
A)textarea
B)selection list
C)text input box
D)submit button
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
12
Which type value for the input element triggers validation in modern browsers?
A) validate
B) text
C) number
D) password
A) validate
B) text
C) number
D) password
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
13
To check if an option button is selected, you access the value of its ____ property.
A) marked
B) selected
C) checked
D) value
A) marked
B) selected
C) checked
D) value
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
14
Modern browsers can perform many validation tasks themselves without any extra JavaScript.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
15
By default, browsers create an collection of form objects that you can reference using array notation.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
16
In modern browsers, which attribute of an input element prevents the form from being submitted if the field is left blank?
A) novalidate
B) required
C) min
D) max
A) novalidate
B) required
C) min
D) max
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
17
You create an empty document fragment using the ____ method.
A)cloneNode()
B) createElement()
C)submit()
D) createDocumentFragment()
A)cloneNode()
B) createElement()
C)submit()
D) createDocumentFragment()
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
18
While JavaScript lets you perform validation in a user's browser, the server-side programs that receive form data generally perform validation as well.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
19
Validation errors found by modern browsers are reported in ____.
A) separate browser windows
B)the Address bar
C)the Status bar
D)bubbles
A) separate browser windows
B)the Address bar
C)the Status bar
D)bubbles
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
20
You can use HTML to set the default value of a selection list so no option is selected.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
21
Match between columns
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
22
How can you add options to a selection list with JavaScript?
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
23
When a control's value is found to be invalid during constraint validation, the ____ event is triggered.
A)input
B)invalid
C)change
D)focus
A)input
B)invalid
C)change
D)focus
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
24
To check a group of fields and trigger an error message if any of them is empty, you use a(n)____ statement.
A) debugger
B)loop
C) console.log()
D)submit
A) debugger
B)loop
C) console.log()
D)submit
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
25
Instead of document.getElementsByTagName("form")[0] , you could use the code
A)document.forms[0]
B)document.form[0]
C) document.getFormElements[0]
D)document.forms.form[0]
A)document.forms[0]
B)document.form[0]
C) document.getFormElements[0]
D)document.forms.form[0]
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
26
Describe two advantages of referencing form objects using methods such as getElementById()rather than the forms array.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
27
Describe the three behaviors that make up the placeholder effect in modern browsers, and that you need toreplicate with JavaScript for older browsers.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
28
Enhancements to HTML and to modern browsers have allowed browsers themselves to perform many validation tasks without any extra JavaScript. This type of validation is known as __________ validation.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
29
__________ is the process of checking that information provided by users conforms to rules to ensure that it appropriately answers a form's questions and is provided in a format that the site's back-end programs can work with.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
30
Creating a function to validate required fields generally involves retrieving the values of the required fields and checking if the value of any of them is __________.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
31
Use of the ____ attribute of the form element is not allowed in the strict DTD for XHTML.
A) id
B) class
C) name
D) method
A) id
B) class
C) name
D) method
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
32
For any fields that require numeric values, you can use JavaScript's built-in ____ function to determine whether a user actually entered a number.
A) submit()
B) reset()
C) validate()
D) isNaN()
A) submit()
B) reset()
C) validate()
D) isNaN()
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
33
Describe how you can use JavaScript to simulate the behavior of the placeholder attribute in older browsers?.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
34
What does a function to validate required fields generally need to do?
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
35
The requirements of the form you're validating determine the kind of logic you need to incorporate into a custom validation program. However, a few types of validation functions are particularly common. Name two.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
36
Why is is usually not necessary to include testing for the number of characters in user input in custom validation functions?
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
37
If you were designing a form with a question that asked users if they had ever visited a certain city, would you expect more accurate input using a text input box or a check box? Why?
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
38
In what situations can you get more accurate information on a form byusing form fields other than text boxes? Name two types of fields you might use instead.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
39
For all custom validation, it can be helpful to use the __________ structure for handling errors.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
40
To send the values entered in a form to a web server with JavaScript, you use the __________ method.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
41
What is an assistive function? Give an example of a situation in which you might use an assistive function.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck