CIST 1520 Chapter 6 (JavaScript)

CIST 1520 Chapter 6 (JavaScript)

memorize.aimemorize.ai (lvl 286)
Section 1

Preview this deck

What property do you use to change the selected option element in a selection list? What value do you use to specify that no option element is selected?

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (27)

Section 1

(27 cards)

What property do you use to change the selected option element in a selection list? What value do you use to specify that no option element is selected?

Front

selectedIndex -1

Back

10. Which of the following input type values triggers browser-based validation in modern browsers? a. password b. text c. radio d. number

Front

number

Back

20. Explain how to check if a user's entry is a number.

Front

JavaScript has a built-in isNaN () (is not a number) function to determine whether the user actually entered a number. If the isNaN () function returns a value of true it is passed a value that is not a number, it it passed a value that is a number the function returns a value of false.

Back

13. What method do you use to disable the default behavior for an event? a. preventDefault() b. checkValidity() c. select() d. getElementById()

Front

preventDefault()

Back

6. Which event do you use to call a function when a field is no longer selected, or a user moves the insertion point to a different field? a. blur b. focus c. click d. forminput

Front

blur

Back

12. Which of the following attributes for form child elements would you use for a field that must have a value before the form can be submitted? a. novalidate b. min c. required d. max

Front

required

Back

17. What is the purpose of the novalidate attribute?

Front

The novalidate attribute toggles off validation of a form when added to the opening <form> tag.

Back

11. Which of the following properties has a value of true when a user has left a required field blank? a. required b. valueMissing c. patternMismatch d. typeMismatch

Front

valueMissing

Back

3. What value of the selectedIndex property of a select object corresponds to no selection? a. -1 b. 0 c. 1 d. false

Front

-1

Back

2. Which of the following type values for the input element does not enable you to provide users with a limited set of choices? a. radio b. email c. checkbox d. range

Front

email

Back

18. Exlain how the validity object of the constraint validation API is used for checking the validity of form data

Front

The statement document.getElementsByTagname ("form") [0]submit () uses the submit () method to submit the form contents manually if data is valid. If the data is invalid - if the formValidity variable has been assigned a value of false - the else clause runs three statements. The first two set the display for the element with id value error Text to block, with a message to the user. The third statement scroll (0,0) moves the browser back to the top of the page so users can see the error Text section and examine the form.

Back

List two attributes that specify parameters for browser-based validation in child elements of a form, and describe what each does See Table 6-12

Front

maxlength -Specifies the control's maximum number of characters required - Indicates that the control must have a value

Back

5. Which event do you use to call a function when a user selects a field or moves the insertion point into a field? a. blur b. focus c. input d. forminput

Front

focus

Back

8. What do you assign to the value property of a text input box to remove its content? a. false b. true c. "" d. null

Front

" "

Back

14. Which statement moves the browser to the top of the page? a. scroll(top) b. scroll(0,0) c. move(top) d. move(0,0)

Front

scroll(0,0)

Back

7. Which of the following attributes determines whether a check box or option button is selected? a. checked b. defaultChecked c. selected d. focus

Front

checked

Back

16. Explain how to transfer the contents of one field to another field.

Front

By creating a function that copies the contents of each field in the billing address fieldset to the corresponding field in the shipping address fieldset. Also adding an event listener to call this function when a user checks this box, and another event listener to clear the values in the shipping address fieldset when user unchecks the box.

Back

15. For any fields that require numeric values, you can use JavaScript's built-in ________ function to determine whether the user actually entered a number. a. value() b. integer() c. isNumber() d. isNaN()

Front

. isNaN()

Back

If you were designing a form with a question that asked users if they owned a bicycle, would you expect more accurate input using a text input box or a check box? Why?

Front

A check box would provide more accurate input. It would allow users to respond only yes (checked) or no (unchecked). If users had to respond by typing in a text input box, they might misspell their input, or enter text that's not easily interpretable as yes or no.

Back

Describe two common uses of JavaScript with forms.

Front

JavaScript is commonly used with forms for two reasons: to add functionality that makes forms easier for users to fill out, and to validate or process the data that a user enters before that data is submitted to a server-side script.

Back

-While JavaScript lets you perform validation in a user's browser, the server-side programs that receive form data generally perform validation as well. a. True b. False

Front

True

Back

Name two advantages of identifying form elements using the getElementById() method rather than by specifying their index numbers within the form.

Front

One advantage of referencing form objects using methods such as getElementById() rather than the forms collection .... 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 nonform 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.

Back

9. Which of the following attributes triggers browser-based validation in modern browsers? a. max b. title c. alt d. src

Front

max

Back

Front

Back

4. To simulate the behavior of placeholder text in older browsers, you can instead set the value of the _______ property. a. src b. alt c. title d. value

Front

value

Back

1. Objects representing each of the controls in a form are stored in the _____ collection. a. forms b. controls c. inputs d. elements

Front

d. elements

Back

19. Explain how to check if any option button in a set is selected.

Front

You access the value of its checked property to check if none of the option buttons in a set are selected, you can create a conditional statement using And (&&) operators. First using the( ! operator ) to check if the first button is not selected, And (&&) to check if the others are not selected. If the conditions are true, the if statement is true, meaning no button is selected.

Back