Exam 6: Enhancing and Validating Forms
Instead of document.getElementsByTagName("form")[0] , you could use the code
A
Describe two advantages of referencing form objects using methods such as getElementById()rather than the forms array.
Any two of the following:
One advantage of referencing form objects using methods such as getElementById( rather than the forms array is that you don't need to switch between using one syntax for referencing form objects and another syntax for non- form objects.
In addition, 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.
Finally, use of the name attribute is not allowed in the strict DTD for XHTML, so if you're writing JavaScript to work with XHTML documents, you cannot use the forms array or other browser arrays.
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.
Sometimes the information requested for a field is restricted to a small, discrete list-the names of a few credit cards, for instance . Asking users to type this information opens your form to the possibility that they'll misspell a word, use an abbreviation that your back-end system doesn't recognize, or simply enter data that's not within the acceptable parameters . Instead, you can use other types of form fields to present users with acceptable choices, and limit their options to those choices.
Any two of the following:
option buttons
selection lists
check boxes
sliders
data lists
By default, browsers create an collection of form objects that you can reference using array notation.
For all custom validation, it can be helpful to use the __________ structure for handling errors.
To check a group of fields and trigger an error message if any of them is empty, you use a(n)____ statement.
To display no default value on a selection list, you set its ____ property to -1.
In modern browsers, which attribute of an input element prevents the form from being submitted if the field is left blank?
You can use HTML to set the default value of a selection list so no option is selected.
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.
When a control's value is found to be invalid during constraint validation, the ____ event is triggered.
Modern browsers can perform many validation tasks themselves without any extra JavaScript.
Which form element is useful for limiting user options to a set of choices?
Validation errors found by modern browsers are reported in ____.
You create an empty document fragment using the ____ method.
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)