0% found this document useful (0 votes)
5 views

CSS Chapter 3 Test

The document consists of a test covering various aspects of JavaScript and HTML forms, including properties and methods of the `form` object, event handling, and dynamic manipulation of form elements. It includes questions requiring code examples and explanations on topics such as input elements, validation, and user interactions. The test aims to assess understanding of form handling and JavaScript functionalities related to web development.

Uploaded by

vawagav635
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

CSS Chapter 3 Test

The document consists of a test covering various aspects of JavaScript and HTML forms, including properties and methods of the `form` object, event handling, and dynamic manipulation of form elements. It includes questions requiring code examples and explanations on topics such as input elements, validation, and user interactions. The test aims to assess understanding of form handling and JavaScript functionalities related to web development.

Uploaded by

vawagav635
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

CSS Chapter 3 Test

1. Explain the properties and methods of the `form` object in JavaScript.

2. Write JavaScript code to dynamically enable and disable a button inside


a form.

3. Differentiate between the `text` and `textarea` input elements in HTML.

4. Write a JavaScript script to retrieve the value entered in a text field


when a button is clicked.

5. Explain the working of radio buttons and checkboxes in an HTML form


with an example.

6. Explain the difference between `onmouseover` and `onmouseout`


events with examples.

7. What are key events in JavaScript? Write an example to capture the


`keypress` event.

8. Explain the `onsubmit` event with an example.

9. Write JavaScript code to change the background color of a text field


when it gains focus (`onfocus`) and revert when it loses focus (`onblur`).

10. List and explain any four mouse events in JavaScript.


11. What is the `document.forms` collection in JavaScript? Explain with an
example.

12. Write JavaScript code to count the number of input elements in a form.

13. Explain how to access and modify form elements using the
`getElementById` method.

14. Describe the `elements` property of the form object.

15. How can you validate form elements before submission? Write an
example.

16. Write JavaScript to dynamically change the `disabled` attribute of a


button.

17. Explain how to change the placeholder text of a text field using
JavaScript.

18. How can you modify the `maxlength` attribute of an input field
dynamically?

19. Write JavaScript code to dynamically change the color of a submit


button.

20. Explain how the `setAttribute()` method is used to modify attributes of


form elements.

21. Write JavaScript code to add new options to a `<select>` dropdown


dynamically.

2
22. Explain how to remove an option from a `<select>` dropdown using
JavaScript.

23. How can you sort the options in a `<select>` dropdown dynamically?

24. Write a JavaScript function that populates a city dropdown list based
on the selected state.

25. Explain the role of the `options` property in dynamically changing a


dropdown list.

26. Write JavaScript code to check if at least one checkbox is selected in a


form.

27. How can you retrieve the values of all selected checkboxes in a form?

28. Explain the difference between `checked` and `defaultChecked`


properties of a checkbox.

29. Write a script that allows selecting all checkboxes in a form when a
"Select All" checkbox is checked.

30. How can you count the number of checkboxes selected by a user?

31. Write JavaScript code to change the text of a label when a button is
clicked.

32. Explain how to use the `innerHTML` property to modify a label


dynamically.

3
33. How can you change the font size and color of a label dynamically using
JavaScript?

34. Write JavaScript to display the entered text dynamically as a label next
to the input field.

35. Explain how `textContent` and `innerText` differ in updating labels.

36. Write JavaScript code to enable or disable a text field based on user
selection.

37. How can you reset all input fields of a form using JavaScript?

38. Explain how to dynamically set focus to a specific form field when a
page loads.

39. Write a script to change the border color of a text field when an
incorrect value is entered.

40. How can you dynamically clone an input field using JavaScript?

41. Explain how the `parseInt()` and `parseFloat()` functions are used in
JavaScript.

42. Write JavaScript to disable an input field when a button is clicked.

43. What is the difference between `disabled` and `readonly` attributes in


form elements?

44. How can you use the `isNaN()` function to validate numeric input
fields?

4
45. Write a JavaScript function to prevent a user from typing in a text field.

You might also like