Deck 6: Enhancing and Validating Forms

Full screen (f)
exit full mode
Question
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
Use Space or
up arrow
down arrow
to flip the card.
Question
You use the ____ method on an object to block the action normally associated with an event.

A)preventDefault()
B)submit()
C)checkValidity()
D)select()
Question
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
Question
In general, modern browsers display validation feedback after the ____ event is triggered by a form.

A) submit
B) reset
C) validate
D) check
Question
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
Question
Which attribute enhances usability in modern browsers?

A) id
B) src
C) placeholder
D) value
Question
To display no default value on a selection list, you set its ____ property to -1.

A) selectedIndex
B) checked
C) selected
D) value
Question
Which attribute toggles off validation of a form when added to the opening
tag?

A) validation
B) submit
C) novalidate
D) nosubmit
Question
The ____ event fires when a form is submitted.

A)clear
B)blur
C)input
D)submit
Question
Assistive functions perform a type of validation.
Question
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
Question
Which type value for the input element triggers validation in modern browsers?

A) validate
B) text
C) number
D) password
Question
To check if an option button is selected, you access the value of its ____ property.

A) marked
B) selected
C) checked
D) value
Question
Modern browsers can perform many validation tasks themselves without any extra JavaScript.
Question
By default, browsers create an collection of form objects that you can reference using array notation.
Question
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
Question
You create an empty document fragment using the ____ method.

A)cloneNode()
B) createElement()
C)submit()
D) createDocumentFragment()
Question
While JavaScript lets you  perform validation in a user's browser, the server-side programs that receive form data generally  perform validation as well.
Question
Validation errors found by modern browsers are reported in ____.

A) separate browser windows
B)the Address bar
C)the Status bar
D)bubbles
Question
You can use HTML to set the default value of a selection list so no option is selected.
Question
Match between columns
Determines whether a value is not a number
bubble
Determines whether a value is not a number
assistive functions
Determines whether a value is not a number
constraint validation API
Determines whether a value is not a number
friction
Determines whether a value is not a number
isNaN()function
Determines whether a value is not a number
validation
Determines whether a value is not a number
placeholder
Determines whether a value is not a number
validity object
Determines whether a value is not a number
preventDefault()
Determines whether a value is not a number
required
Enables customization of validation feedback in modern browsers
bubble
Enables customization of validation feedback in modern browsers
assistive functions
Enables customization of validation feedback in modern browsers
constraint validation API
Enables customization of validation feedback in modern browsers
friction
Enables customization of validation feedback in modern browsers
isNaN()function
Enables customization of validation feedback in modern browsers
validation
Enables customization of validation feedback in modern browsers
placeholder
Enables customization of validation feedback in modern browsers
validity object
Enables customization of validation feedback in modern browsers
preventDefault()
Enables customization of validation feedback in modern browsers
required
Indicates that a form element must have a value
bubble
Indicates that a form element must have a value
assistive functions
Indicates that a form element must have a value
constraint validation API
Indicates that a form element must have a value
friction
Indicates that a form element must have a value
isNaN()function
Indicates that a form element must have a value
validation
Indicates that a form element must have a value
placeholder
Indicates that a form element must have a value
validity object
Indicates that a form element must have a value
preventDefault()
Indicates that a form element must have a value
required
Checking that information provided by users conforms to rules
bubble
Checking that information provided by users conforms to rules
assistive functions
Checking that information provided by users conforms to rules
constraint validation API
Checking that information provided by users conforms to rules
friction
Checking that information provided by users conforms to rules
isNaN()function
Checking that information provided by users conforms to rules
validation
Checking that information provided by users conforms to rules
placeholder
Checking that information provided by users conforms to rules
validity object
Checking that information provided by users conforms to rules
preventDefault()
Checking that information provided by users conforms to rules
required
If all its properties are false , then its value is true
bubble
If all its properties are false , then its value is true
assistive functions
If all its properties are false , then its value is true
constraint validation API
If all its properties are false , then its value is true
friction
If all its properties are false , then its value is true
isNaN()function
If all its properties are false , then its value is true
validation
If all its properties are false , then its value is true
placeholder
If all its properties are false , then its value is true
validity object
If all its properties are false , then its value is true
preventDefault()
If all its properties are false , then its value is true
required
Stops a form from being submitted when the submit event is triggered
bubble
Stops a form from being submitted when the submit event is triggered
assistive functions
Stops a form from being submitted when the submit event is triggered
constraint validation API
Stops a form from being submitted when the submit event is triggered
friction
Stops a form from being submitted when the submit event is triggered
isNaN()function
Stops a form from being submitted when the submit event is triggered
validation
Stops a form from being submitted when the submit event is triggered
placeholder
Stops a form from being submitted when the submit event is triggered
validity object
Stops a form from being submitted when the submit event is triggered
preventDefault()
Stops a form from being submitted when the submit event is triggered
required
Persistence required for a user to accomplish a goal
bubble
Persistence required for a user to accomplish a goal
assistive functions
Persistence required for a user to accomplish a goal
constraint validation API
Persistence required for a user to accomplish a goal
friction
Persistence required for a user to accomplish a goal
isNaN()function
Persistence required for a user to accomplish a goal
validation
Persistence required for a user to accomplish a goal
placeholder
Persistence required for a user to accomplish a goal
validity object
Persistence required for a user to accomplish a goal
preventDefault()
Persistence required for a user to accomplish a goal
required
Displays a validation error in a modern browser
bubble
Displays a validation error in a modern browser
assistive functions
Displays a validation error in a modern browser
constraint validation API
Displays a validation error in a modern browser
friction
Displays a validation error in a modern browser
isNaN()function
Displays a validation error in a modern browser
validation
Displays a validation error in a modern browser
placeholder
Displays a validation error in a modern browser
validity object
Displays a validation error in a modern browser
preventDefault()
Displays a validation error in a modern browser
required
Reduce the likelihood of user errors when completing a form
bubble
Reduce the likelihood of user errors when completing a form
assistive functions
Reduce the likelihood of user errors when completing a form
constraint validation API
Reduce the likelihood of user errors when completing a form
friction
Reduce the likelihood of user errors when completing a form
isNaN()function
Reduce the likelihood of user errors when completing a form
validation
Reduce the likelihood of user errors when completing a form
placeholder
Reduce the likelihood of user errors when completing a form
validity object
Reduce the likelihood of user errors when completing a form
preventDefault()
Reduce the likelihood of user errors when completing a form
required
Provides guidance about what data should be entered in a text box
bubble
Provides guidance about what data should be entered in a text box
assistive functions
Provides guidance about what data should be entered in a text box
constraint validation API
Provides guidance about what data should be entered in a text box
friction
Provides guidance about what data should be entered in a text box
isNaN()function
Provides guidance about what data should be entered in a text box
validation
Provides guidance about what data should be entered in a text box
placeholder
Provides guidance about what data should be entered in a text box
validity object
Provides guidance about what data should be entered in a text box
preventDefault()
Provides guidance about what data should be entered in a text box
required
Question
How can you add options to a selection list with JavaScript?
Question
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
Question
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
Question
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]
Question
Describe two advantages of referencing form objects using methods such as getElementById()rather than the forms array.
Question
Describe the three behaviors that make up the placeholder effect in modern browsers, and that you need toreplicate with JavaScript for older browsers.
Question
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.
Question
__________ 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.
Question
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 __________.
Question
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
Question
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()
Question
Describe how you can use JavaScript to simulate the behavior of the placeholder attribute in older browsers?.
Question
What does a function to validate required fields generally need to do?
Question
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.
Question
Why is is usually not necessary to include testing for the number of characters in user input in custom validation functions?
Question
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?
Question
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. 
Question
For all custom validation, it can be helpful to use the __________  structure for handling errors.
Question
To send the values entered in a form to a web server with JavaScript, you use the __________ method.
Question
What is an assistive function? Give an example of a situation in which you might use an assistive function.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/41
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
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
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
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
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
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
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
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
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
tag?

A) validation
B) submit
C) novalidate
D) nosubmit
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
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
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
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
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
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()
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
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
Determines whether a value is not a number
bubble
Determines whether a value is not a number
assistive functions
Determines whether a value is not a number
constraint validation API
Determines whether a value is not a number
friction
Determines whether a value is not a number
isNaN()function
Determines whether a value is not a number
validation
Determines whether a value is not a number
placeholder
Determines whether a value is not a number
validity object
Determines whether a value is not a number
preventDefault()
Determines whether a value is not a number
required
Enables customization of validation feedback in modern browsers
bubble
Enables customization of validation feedback in modern browsers
assistive functions
Enables customization of validation feedback in modern browsers
constraint validation API
Enables customization of validation feedback in modern browsers
friction
Enables customization of validation feedback in modern browsers
isNaN()function
Enables customization of validation feedback in modern browsers
validation
Enables customization of validation feedback in modern browsers
placeholder
Enables customization of validation feedback in modern browsers
validity object
Enables customization of validation feedback in modern browsers
preventDefault()
Enables customization of validation feedback in modern browsers
required
Indicates that a form element must have a value
bubble
Indicates that a form element must have a value
assistive functions
Indicates that a form element must have a value
constraint validation API
Indicates that a form element must have a value
friction
Indicates that a form element must have a value
isNaN()function
Indicates that a form element must have a value
validation
Indicates that a form element must have a value
placeholder
Indicates that a form element must have a value
validity object
Indicates that a form element must have a value
preventDefault()
Indicates that a form element must have a value
required
Checking that information provided by users conforms to rules
bubble
Checking that information provided by users conforms to rules
assistive functions
Checking that information provided by users conforms to rules
constraint validation API
Checking that information provided by users conforms to rules
friction
Checking that information provided by users conforms to rules
isNaN()function
Checking that information provided by users conforms to rules
validation
Checking that information provided by users conforms to rules
placeholder
Checking that information provided by users conforms to rules
validity object
Checking that information provided by users conforms to rules
preventDefault()
Checking that information provided by users conforms to rules
required
If all its properties are false , then its value is true
bubble
If all its properties are false , then its value is true
assistive functions
If all its properties are false , then its value is true
constraint validation API
If all its properties are false , then its value is true
friction
If all its properties are false , then its value is true
isNaN()function
If all its properties are false , then its value is true
validation
If all its properties are false , then its value is true
placeholder
If all its properties are false , then its value is true
validity object
If all its properties are false , then its value is true
preventDefault()
If all its properties are false , then its value is true
required
Stops a form from being submitted when the submit event is triggered
bubble
Stops a form from being submitted when the submit event is triggered
assistive functions
Stops a form from being submitted when the submit event is triggered
constraint validation API
Stops a form from being submitted when the submit event is triggered
friction
Stops a form from being submitted when the submit event is triggered
isNaN()function
Stops a form from being submitted when the submit event is triggered
validation
Stops a form from being submitted when the submit event is triggered
placeholder
Stops a form from being submitted when the submit event is triggered
validity object
Stops a form from being submitted when the submit event is triggered
preventDefault()
Stops a form from being submitted when the submit event is triggered
required
Persistence required for a user to accomplish a goal
bubble
Persistence required for a user to accomplish a goal
assistive functions
Persistence required for a user to accomplish a goal
constraint validation API
Persistence required for a user to accomplish a goal
friction
Persistence required for a user to accomplish a goal
isNaN()function
Persistence required for a user to accomplish a goal
validation
Persistence required for a user to accomplish a goal
placeholder
Persistence required for a user to accomplish a goal
validity object
Persistence required for a user to accomplish a goal
preventDefault()
Persistence required for a user to accomplish a goal
required
Displays a validation error in a modern browser
bubble
Displays a validation error in a modern browser
assistive functions
Displays a validation error in a modern browser
constraint validation API
Displays a validation error in a modern browser
friction
Displays a validation error in a modern browser
isNaN()function
Displays a validation error in a modern browser
validation
Displays a validation error in a modern browser
placeholder
Displays a validation error in a modern browser
validity object
Displays a validation error in a modern browser
preventDefault()
Displays a validation error in a modern browser
required
Reduce the likelihood of user errors when completing a form
bubble
Reduce the likelihood of user errors when completing a form
assistive functions
Reduce the likelihood of user errors when completing a form
constraint validation API
Reduce the likelihood of user errors when completing a form
friction
Reduce the likelihood of user errors when completing a form
isNaN()function
Reduce the likelihood of user errors when completing a form
validation
Reduce the likelihood of user errors when completing a form
placeholder
Reduce the likelihood of user errors when completing a form
validity object
Reduce the likelihood of user errors when completing a form
preventDefault()
Reduce the likelihood of user errors when completing a form
required
Provides guidance about what data should be entered in a text box
bubble
Provides guidance about what data should be entered in a text box
assistive functions
Provides guidance about what data should be entered in a text box
constraint validation API
Provides guidance about what data should be entered in a text box
friction
Provides guidance about what data should be entered in a text box
isNaN()function
Provides guidance about what data should be entered in a text box
validation
Provides guidance about what data should be entered in a text box
placeholder
Provides guidance about what data should be entered in a text box
validity object
Provides guidance about what data should be entered in a text box
preventDefault()
Provides guidance about what data should be entered in a text box
required
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
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
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]
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
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()
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
locked card icon
Unlock Deck
Unlock for access to all 41 flashcards in this deck.