Forms Flashcards

1
Q

What is the purpose of the HTML <form> element?

A

It provides interactive controls for user data input and submission, validates user input, and sends data to a server.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does the action attribute of the <form> element specify?

A

The URL where the form data is sent, containing name/value pairs of form controls.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the two common HTTP methods for form submission, and how do they differ?

A

GET sends data as a query string in the URL, while POST sends data in the HTTP request body, making it more secure for sensitive data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the method="POST" attribute do in a form submission?

A

It sends form data in the HTTP request body, which is more secure for sensitive data like passwords.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the purpose of the name attribute in form controls?

A

It identifies form controls and helps with server-side data processing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do radio buttons behave in a form?

A

They share the same name attribute, ensuring only one button in a group is selected, and the selected button’s name=value pair is submitted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do checkboxes behave in a form?

A

They can share the same name, and only selected checkboxes are submitted with their name and value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the purpose of the for attribute in <label> elements?</label>

A

It associates the label with a form control by matching the control’s id, improving accessibility.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does the capture attribute do in a file input field?

A

It allows the use of the device’s camera or microphone to capture media, with options for front (capture="user") or back (capture="environment") devices.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How does the pattern attribute in form inputs work?

A

It specifies a regular expression (regex) that input must match for validation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does the type="file" input allow users to do?

A

It allows users to upload files, with restrictions based on the accept attribute (e.g., images only).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How does the input type affect the mobile keyboard appearance?

A

Input types like tel and email change the keyboard layout to be optimized for their respective data (e.g., number keypad for phone numbers, email keyboard with @ and .).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly