MCQs Of Class 12Forms in HTML - Part 3
Multiple-Choice Questions
1. Which HTML attribute
specifies that an input field is mandatory to be filled out before form
submission?
o A) required
o B) mandatory
o C) validate
o D) check
Answer: A) required
2. What does the fieldset
element in HTML forms do?
o A) Groups related
elements in a form and adds a border around them
o B) Creates a new form
o C) Defines a single-line
input field
o D) Submits the form data
Answer: A) Groups related elements in a form and adds a border
around them
3. Which HTML element is
used to create a dropdown menu in a form?
o A) <input>
o B) <select>
o C) <textarea>
o D) <button>
Answer: B) <select>
4. How can you ensure that
a text area has a minimum number of characters?
o A) Using the minlength
attribute
o B) Using the maxlength
attribute
o C) Using the required
attribute
o D) Using the pattern
attribute
Answer: A) Using the minlength attribute
5. Which attribute is used
to specify a default value for a form input field?
o A) value
o B) default
o C) initial
o D) preset
Answer: A) value
6. What is the purpose of
the action attribute in the <form> element?
o A) Defines the URL where
form data will be sent
o B) Specifies the type of
form input
o C) Indicates the method
of form submission
o D) Styles the form
elements
Answer: A) Defines the URL where form data will be sent
7. Which HTML tag is used
to define a clickable button in a form?
o A) <input
type="button">
o B) <button>
o C) <a>
o D) <submit>
Answer: B) <button>
8. What type of input field
is created using <input type="file">?
o A) Text Input
o B) Date Picker
o C) File Upload
o D) Radio Button
Answer: C) File Upload
9. How can you create a
radio button group in HTML?
o A) Use multiple
<input> elements with the same name attribute and different value
attributes
o B) Use a <select>
element with <option> elements
o C) Use a
<textarea> element
o D) Use a single
<input> element with multiple value attributes
Answer: A) Use multiple <input> elements with the same name
attribute and different value attributes
10.
Which attribute can be used to provide a hint about the expected
value of an input field?
o A) placeholder
o B) hint
o C) value
o D) description
Answer: A) placeholder
11.
Which HTML attribute specifies that a form should be submitted
using the GET method?
o A)
method="get"
o B) type="get"
o C)
action="get"
o D) submit="get"
Answer: A) method="get"
12.
Which of the following is the correct HTML tag for a submit button
in a form?
o A) <input
type="submit">
o B) <button
type="submit">
o C) <button submit>
o D) <input
type="button" submit>
Answer: A) <input type="submit">
13.
What does the enctype attribute of the <form> element
specify?
o A) The encoding type of
form data
o B) The form submission
method
o C) The destination URL
for the form data
o D) The form field labels
Answer: A) The encoding type of form data
14.
How do you define a checkbox input in an HTML form?
o A) <input
type="checkbox">
o B) <input
type="radio">
o C) <input
type="text">
o D) <input
type="button">
Answer: A) <input type="checkbox">
15.
Which attribute is used to add a tooltip that appears when a user
hovers over an input field?
o A) title
o B) tooltip
o C) hint
o D) info
Answer: A) title
15. What is the purpose of
the autocomplete attribute in an HTML form?
o A) To enable or disable
browser auto-fill for input fields
o B) To automatically
submit the form
o C) To set default values
in input fields
o D) To validate form
inputs automatically
Answer: A) To enable or disable browser auto-fill for input fields
2. Which HTML element is
used to create a form that allows multiple file uploads?
o A) <input
type="file" multiple>
o B) <input
type="upload" multiple>
o C) <file-upload
multiple>
o D) <input
type="files">
Answer: A) <input type="file" multiple>
16. How do you specify that
a form should be submitted using the POST method?
o A)
method="post"
o B)
action="post"
o C) type="post"
o D)
submit="post"
Answer: A) method="post"
17. Which attribute in the
<input> tag specifies the type of data expected in a form field?
o A) type
o B) data
o C) value
o D) format
Answer: A) type
18. What does the name
attribute in form elements do?
o A) It defines the
identifier for the form element, used to reference form data when the form is
submitted
o B) It sets the form
element's display style
o C) It specifies the form
element's default value
o D) It creates a unique
identifier for the form element
Answer: A) It defines the identifier for the form element, used to
reference form data when the form is submitted
19. What is the default
value of the method attribute in an HTML form if not specified?
o A) GET
o B) POST
o C) PUT
o D) DELETE
Answer: A) GET
20. Which HTML attribute
specifies the URL to which the form data will be sent?
o A) action
o B) method
o C) target
o D) enctype
Answer: A) action
21. What does the required
attribute do when applied to a form input element?
o A) It makes the input
field mandatory for form submission
o B) It specifies the
maximum number of characters allowed
o C) It sets a default
value for the input field
o D) It defines the
placeholder text for the input field
Answer: A) It makes the input field mandatory for form submission
22. How can you make an
input field accept only numerical values?
o A) By using
type="number"
o B) By using
type="text"
o C) By using
type="numeric"
o D) By using
type="integer"
Answer: A) By using type="number"
23.
Which of the following attributes is used to set the maximum
length of characters allowed in a text input field?
o A) maxlength
o B) max
o C) length
o D) size
Answer: A) maxlength
24.
Which tag is used to create a hidden input field in a form?
o A) <input
type="hidden">
o B) <hidden>
o C) <input
type="secret">
o D) <input
type="password">
Answer: A) <input type="hidden">
25.
What does the pattern attribute do in a form input field?
o A) It specifies a
regular expression the input value must match
o B) It sets a default
pattern for text input
o C) It specifies the
input field's background pattern
o D) It defines the input
field's text pattern
Answer: A) It specifies a regular expression the input value must
match
26.
Which form element is used to group a set of related checkboxes?
o A) <fieldset>
o B) <group>
o C) <checkboxes>
o D) <grouping>
Answer: A) <fieldset>
27.
How do you prevent form submission if a required field is empty?
o A) By using the required
attribute on the input field
o B) By setting disabled
on the submit button
o C) By using JavaScript
to validate the form
o D) By using CSS to hide
the submit button
Answer: A) By using the required attribute on the input field
28.
Which HTML attribute can be used to add a default suggestion or
hint in a form input field?
o A) placeholder
o B) hint
o C) info
o D) suggestion
Answer: A) placeholder
29. Which HTML tag is used
to group related input elements together in a form?
o A) <div>
o B) <section>
o C) <fieldset>
o D) <group>
Answer: C) <fieldset>
30. What does the label
element do in an HTML form?
o A) Provides a label for
an input element, improving accessibility and user experience
o B) Styles the input
field
o C) Defines the form's
submission URL
o D) Sets default values
for the form elements
Answer: A) Provides a label for an input element, improving
accessibility and user experience
31. Which attribute of the
<input> element specifies the form field type for entering a date?
o A) type="date"
o B) type="datetime"
o C)
type="calendar"
o D) type="time"
Answer: A) type="date"
32. How can you create a
form that submits data to a server using the POST method and includes file
upload functionality?
o A) <form
method="post" enctype="multipart/form-data">
o B) <form
method="post" enctype="text/plain">
o C) <form
method="get"
enctype="application/x-www-form-urlencoded">
o D) <form
method="post" enctype="application/json">
Answer: A) <form method="post"
enctype="multipart/form-data">
33. What does the
autocomplete attribute value off do?
o A) Prevents the browser
from automatically filling in input fields with previously entered data
o B) Enables the browser
to fill in the input fields with suggested data
o C) Sets default values
for the input fields
o D) Enforces the use of
auto-correct in input fields
Answer: A) Prevents the browser from automatically filling in input
fields with previously entered data
34. Which HTML element is
used to define a set of radio buttons that allow only one option to be selected
at a time?
o A) <input
type="radio">
o B) <input
type="checkbox">
o C) <input
type="button">
o D) <select>
Answer: A) <input type="radio">
35. How can you ensure that
a form submission is canceled if certain validation criteria are not met?
o A) Use JavaScript to
validate the form before submission
o B) Use the required
attribute on input fields
o C) Set the method
attribute to none
o D) Add a disabled
attribute to the form
Answer: A) Use JavaScript to validate the form before submission
36. Which attribute is used
to specify the maximum number of characters allowed in a <textarea>
element?
o A) maxlength
o B) maxchars
o C) limit
o D) size
Answer: A) maxlength
37. What does the multiple
attribute do when applied to a file input element?
o A) Allows multiple files
to be selected for upload
o B) Enables multiple
lines of text input
o C) Allows multiple
default values to be set
o D) Provides multiple
options for text suggestions
Answer: A) Allows multiple files to be selected for upload
38.
Which attribute should be used to add a description that appears
when a user hovers over an input field?
o A) title
o B) description
o C) tooltip
o D) hint
Answer: A) title
39.
How do you set up a form to submit data in JSON format?
o A) Set the enctype
attribute to application/json and use JavaScript to format the data
o B) Set the method
attribute to json and use HTML5 features
o C) Use the data-type
attribute to specify json
o D) Use the
application/json content type in the server-side script
Answer: A) Set the enctype attribute to application/json and use
JavaScript to format the data
40.
What does the method="get" attribute do when included in
a form element?
o A) Submits the form data
as URL parameters
o B) Submits the form data
in the request body
o C) Uses cookies to store
form data
o D) Encrypts the form
data before submission
Answer: A) Submits the form data as URL parameters
41.
How can you define a default selected option in a dropdown list?
o A) By using the selected
attribute in the <option> tag
o B) By using the default
attribute in the <select> tag
o C) By setting the
checked attribute in the <option> tag
o D) By using the value
attribute in the <select> tag
Answer: A) By using the selected attribute in the <option> tag
42.
Which HTML tag is used to define a submit button within a form?
o A) <button
type="submit">
o B) <input
type="submit">
o C) <form-button>
o D) <submit>
Answer: B) <input type="submit">
43.
What is the purpose of the action attribute in the <form>
tag?
o A) To define the URL to
which the form data will be sent upon submission
o B) To specify the type
of form submission
o C) To validate form
inputs
o D) To set the appearance
of the form
Answer: A) To define the URL to which the form data will be sent
upon submission
44. Which attribute is used
to specify the name of the form that will handle the submitted form data?
o A) action
o B) method
o C) target
o D) formaction
Answer: D) formaction
45. How do you create a form
that will submit data to a server and then redirect the user to a different
page?
o A) Use JavaScript to
handle form submission and redirection
o B) Set the action
attribute to the target URL
o C) Use the redirect
attribute in the <form> tag
o D) Use a meta refresh
tag in the HTML header
Answer: A) Use JavaScript to handle form submission and redirection
46. What does the novalidate
attribute do when applied to a <form> element?
o A) Disables HTML5 form
validation
o B) Enables server-side
validation
o C) Specifies client-side
validation options
o D) Makes the form
automatically validated
Answer: A) Disables HTML5 form validation
47. Which attribute
specifies the URL where the form data should be sent when the form is
submitted?
o A) method
o B) action
o C) enctype
o D) target
Answer: B) action
48. Which input type is used
to create a hidden field in a form?
o A) hidden
o B) password
o C) text
o D) email
Answer: A) hidden
49. How can you ensure that
a form field only accepts valid email addresses?
o A) Use
type="email" in the <input> tag
o B) Apply a regular
expression pattern to the field
o C) Use the validate
attribute
o D) Implement server-side
validation
Answer: A) Use type="email" in the <input> tag
50 What attribute would you
use to make a form field optional rather than required?
o A) optional
o B) required
o C) default
o D) No specific attribute
is needed
Answer: D) No specific attribute is needed
51. How do you define a form
that accepts only numeric input?
o A)
type="number"
o B) type="text"
o C)
type="numeric"
o D)
type="integer"
Answer: A) type="number"
52. Which HTML tag is used
to create a group of checkboxes that are mutually exclusive?
o A) <input
type="checkbox"> with the same name attribute
o B) <input
type="radio"> with the same name attribute
o C) <select> with
multiple <option> tags
o D) <input
type="button"> with JavaScript handling
Answer: B) <input type="radio"> with the same name
attribute
53.
What does the action attribute of a form tag do when using the
POST method?
o A) Specifies where the
form data is sent
o B) Defines how the form
data is encoded
o C) Indicates which
method to use for form submission
o D) Sets the visual style
of the form
Answer: A) Specifies where the form data is sent
54.
Which attribute can be used to define a custom validation message
for a required field?
o A) title
o B) placeholder
o C) data-error
o D) message
Answer: A) title
55.
Which input type allows a user to select a color from a color
picker?
o A) color
o B) text
o C) range
o D) date
Answer: A) color
56.
How can you set a form to submit data to a new tab or window?
o A) Use
target="_blank" in the <form> tag
o B) Use JavaScript to
open a new window
o C) Set
method="new" in the <form> tag
o D) Specify a new URL in
the action attribute
Answer: B) Use JavaScript to open a new window
57.
Which attribute specifies that a form input field should only
accept a certain type of data, such as a URL or email address?
o A) type
o B) pattern
o C) format
o D) accept
Answer: A) type
58.
What is the purpose of the enctype attribute in the <form>
tag?
o A) Specifies the
encoding type for form data
o B) Defines the form
submission URL
o C) Sets the method for
data submission
o D) Indicates where to
redirect after form submission
Answer: A) Specifies the encoding type for form data
59. What is the purpose of
the form attribute in an <input> element?
o A) Links the input field
to a specific form
o B) Specifies the form
method
o C) Defines the form
submission action
o D) Provides styling
options for the form
Answer: A) Links the input field to a specific form
60. Which HTML attribute is
used to specify a maximum length for an input field?
o A) maxlength
o B) size
o C) limit
o D) maxsize
Answer: A) maxlength
61. How can you create a
form that submits data to the server but does not reload the page?
o A) Use JavaScript with
AJAX to handle the form submission
o B) Set the method
attribute to ajax
o C) Use a <button>
element instead of a <submit> button
o D) Include the noreload
attribute in the form tag
Answer: A) Use JavaScript with AJAX to handle the form submission
62. Which input type is used
to create a field that accepts a user’s phone number?
o A) tel
o B) number
o C) text
o D) phone
Answer: A) tel
63. What does the required
attribute do when applied to an input field?
o A) Makes the field
mandatory to fill out before form submission
o B) Sets a default value
for the input field
o C) Hides the input field
from the user
o D) Validates the input
field with a regular expression
Answer: A) Makes the field mandatory to fill out before form
submission
64. Which attribute should
you use to provide a default value in a text input field?
o A) value
o B) placeholder
o C) default
o D) initial
Answer: A) value
65. What does the readonly
attribute do for an input field?
o A) Prevents the user
from modifying the field’s value
o B) Makes the field
invisible to the user
o C) Allows the field to
be edited but not submitted
o D) Sets a default value
for the field
Answer: A) Prevents the user from modifying the field’s value
66. Which attribute
specifies the type of file that can be uploaded using a file input field?
o A) accept
o B) type
o C) filter
o D) upload
Answer: A) accept
67. How can you group
multiple form elements to ensure they are submitted together?
o A) Use the
<fieldset> tag
o B) Use the group
attribute
o C) Place them inside a
<div> tag
o D) Apply a common class
to the elements
Answer: A) Use the <fieldset> tag
68.
What is the purpose of the action attribute in a form element?
o A) Specifies where to
send the form data upon submission
o B) Defines how the form
should be styled
o C) Indicates the method
of form validation
o D) Sets the form's
default values
Answer: A) Specifies where to send the form data upon submission
69.
How do you ensure that a form field value is unique within the
form?
o A) Use JavaScript to
validate the uniqueness before submission
o B) Apply the unique
attribute to the input field
o C) Set the name
attribute to a distinct value
o D) Use server-side
validation
Answer: A) Use JavaScript to validate the uniqueness before
submission
70.
Which HTML element is used to create a group of options for a
select dropdown?
o A) <option>
o B) <select>
o C) <optgroup>
o D) <fieldset>
Answer: C) <optgroup>
71.
What does the formtarget attribute do in a submit button?
o A) Specifies where to
open the form's response (e.g., in a new tab or frame)
o B) Defines the form's
submission method
o C) Sets the form's
action URL
o D) Provides styling
options for the form
Answer: A) Specifies where to open the form's response (e.g., in a
new tab or frame)
72.
Which attribute of the <input> tag is used to specify a
placeholder text that appears when the input is empty?
o A) placeholder
o B) default
o C) hint
o D) label
Answer: A) placeholder
73.
What is the role of the formaction attribute in a submit button?
o A) Overrides the form's
action attribute with a specific URL for the button's submission
o B) Defines the button’s
appearance
o C) Sets the method for
the form submission
o D) Specifies the
encoding type for the form data
Answer: A) Overrides the form's action attribute with a specific URL
for the button's submission
