HTML Forms Flashcards

1
Q

What elements help structure and organize forms?

A

Fieldset and legend. Both are important to screen readers. Particularly useful for radio and checkbox sections.

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

What is the point of a name attribute in a form input?

A

Only named inputs will be sent to server; name radio buttons in same group with same name so they behave correctly.

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

How do you create a textarea and set its height and width?

A

Use cols and rows attributes in the element, they’re required; use css as well, ideally height=auto, which will correspond to the row attribute.

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

How can you create an HTML-only input with custom autocomplete terms?

A

Use an input with type text and a “list” attribute that points to ID of a datalist element. No need for autocomplete=”on”. The datalist contains option elements.

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

Make a radio button or checkbox selected by default.

A

use the ‘checked’ attribute, just ‘checked’ no =true or anything like that.

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

Set minimum, maximum, and increment for inputs of type ‘number’ and ‘range’

A

min=”0” max=”100” step=”10” // increments between 0 and 100 in steps of 10.

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

How would you hide a form element and why would you do it?

A

Set type=”hidden”, and make sure to have a name and a value. Do it to send data to server.

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

How can you add ticks to a slider type of input?

A

If the input includes steps attribute, ie and edge will display ticks. Chrome and Safari will display if you use a datalist with the right number of options. FF requires some prefixed styling.

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

An input field requires that the user types text matching an uppercase letter followed by 3 numbers followed by any number of any character

A

[input type=”text” required pattern=”[A-Z][0-9]{3}.*”] (note quotes not slashes; it ends in dot (any character) and asterisk (any number of times)

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

What form attribute must be present to use custom JS validation?

A

The form element should contain the attribute ‘novalidate’

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

myInputElement.addEventListener( [what goes here?], function… for listening to changes in the input field?

A

myInputElement.addEventListener(‘input’, function… or keyup or others…

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

What attribute makes sure that our custom error message will be presented to everyone?

A

aria-live

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

To change styling of difficult-to-style elements such as search fields, use what attributes and values?

A

appearance, -webkit-appearance, -moz-appearance. Value should be ‘none’ or ‘textfield’ or several others.

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

To restrict user’s ability to drag textarea fields in all directions, use what property/value?

A

resize: vertical

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

Can you style an input that displays a placeholder?

A

Use input:placeholder-shown.

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