Web Technology Questions and Answers – Creating a Form with the Form Element

This set of Web Technology Multiple Choice Questions & Answers (MCQs) focuses on “Creating a Form with the Form Element”.

1. A <form> element cannot contain which element?
a) Paragraph
b) Heading
c) Form
d) Body
View Answer

Answer: c
Explanation: One should keep your <form> elements separate from each other. And no <form> element contains another <form> element. A page may contain as many forms as you like.

2. A form element should contain how many attributes at least?
a) 0
b) 2
c) 4
d) 6
View Answer

Answer: b
Explanation: Every <form> element should carry at least two attributes: action and method. A <form> element may also carry all the universal attributes, the UI event attributes, and the following attributes: enctype, accept, accept-charset, onsubmit, onreset.

3. What is an action attribute?
a) Indicates what happens to the data when the form is submitted
b) Indicates which action to be needed for the data in the form so it can be processed
c) Tells if an action is needed while an error or interruption occurs
d) It fixes the error which occurred and needs a confirmation to proceed
View Answer

Answer: a
Explanation: The action attribute indicates what happens to the data when the form is submitted. Usually, the value of the action attribute is a page or program on a web server that will receive the information.
advertisement
advertisement

4. What is method attribute?
a) Indicates which method type is needed for the form data
b) Form data can be sent to the server in two ways, each corresponding to an HTTP method
c) Describes for the elements and attributes in a given method
d) None of the mentioned
View Answer

Answer: b
Explanation: The method attribute helps the form data to be sent to the server in two ways. The get method, which sends data as part of the URL. The post method, which hides data in something known as the HTTP headers.

5. How does an onsubmit attribute help?
a) After hitting the submit button, it asks for the confirmation of the details
b) It shows any errors or missing data in the form
c) It helps to modify the form after the submission
d) Shows an error immediately after entering the data in the form
View Answer

Answer: b
Explanation: When you enter a data in incorrect format or forgotten to enter data, the chances are, you have come across a form that uses the onsubmit attribute to run a script in the browser that checks the data you entered before the form is sent to the server.

6. Describe about the onreset attribute?
a) It clears the whole form
b) It asks for the confirmation before hitting the clear form option
c) It fills the form to the default values
d) It helps in modifying the form after the submission
View Answer

Answer: a
Explanation: When the onreset attribute is used, its value is a script (as with the onsubmit attribute) that is executed when the user clicks the button that calls it. If you offer a Clear Form button, however, it is good to confirm with users that they did intend to clear the form before performing the action.

7. What is an enctype attribute?
a) To specify the browser in which kind it should be encrypted
b) To show the encoded format before sending the data to the server
c) To specify how the browser encodes the data after sending it to the server
d) To specify how the browser encodes the data before it sends it to the server
View Answer

Answer: d
Explanation: Browsers tend to support two types of encoding.The “application/x – www – form – urlencoded”, which is the standard method most forms use. The “multipart/form – data” , which allows the data to be sent in parts, where each consecutive part corresponds to a form control, in the order it appears in the form.
advertisement

8. What does an accept-charset attribute specify?
a) It specifies a list of character encodings that the user has newly created
b) It specifies a list of character encodings that a user may enter, and that the server can then process
c) It specifies a list of character encodings which are used
d) It specifies a list of character encodings which are used by the server
View Answer

Answer: b
Explanation: Different languages are written in different character sets or groups of characters. However, when creating web sites, developers do not always build them to understand all different languages. Values should be a space-separated or comma-delimited list of character sets.

9. What is an accept attribute?
a) It is an older version of accept-charset which is deprecated
b) It the later version of accept-charset with few exceptions
c) It takes a comma-separated list of content types that the server processing the form can handle
d) It takes everything except comma-separated list
View Answer

Answer: c
Explanation: The idea is that a user would not be able to upload a file of a different content type other than those listed. Here, you can see that the only types intended to be uploaded are images that are GIFs or JPEGs.
advertisement

10. What is the default value of enctype attribute?
a) application/x – www – form – urlencoded
b) multipart/form – data
c) no default values
d) multipart/data
View Answer

Answer: a
Explanation: If the enctype attribute is not used, browsers use application/x – www – form – urlencoded. If non – ASCII characters are being used, the multipart/form – data value is used. The enctype is likely is used only if your form allows users to upload a file (such as an image) to the server.

Sanfoundry Global Education & Learning Series – Web Technology.

To practice all areas of Web Technology, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.