7 Forms Flashcards

1
Q

Get input from the user (html side)

A

&ltform>

&lt/form>

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

Every form requires an action

t or f

A

t

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

Specify specific file name to output form information to

A

action=”filename and location”

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

Add the values from the form to the end of the URL

Used to request data from a specified resource.

A

method=”get”

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

Send the values to HTTP headers

Used to send data to a server to create/update a resource.

A

method=”post”

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

When do you use

method=”get” (2 situations)

A

short forms (such as search boxes)

when you are just retrieving
data from the web server
(not sending information that
should be added to or deleted
from a database)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

When do you use

method=”post” (4 situations)

A

If your form:
allows users to upload a file

is very long

contains sensitive data
(e.g. passwords)

adds information to, or deletes information from, a
database

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

Control size of form

A

size attribute

but just use CSS now

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

What are the kinds of inputs?
(18 kinds)
Which of them do not follow the input type=”” format? (2) And what goes in the middle for them?

A

&ltinput type=”text” />

&ltinput type=”search”/>

&ltinput type=”password”/>

&ltinput type=”email”/>

&ltinput type=”url”/>

&lttextarea> default text &lt/textarea>

&ltinput type=”radio”/>
(name=”” to define a group)
(checked=”checked” to set which one starts checked)

&ltinput type=”checkbox”/>
(name=”” to define a group)
(checked=”checked” to set which one starts checked)

&ltinput type=”range”/>

&ltselect>
&ltoption> option text &lt/option>
&ltoption> option text &lt/option>
&lt/select>
(selected=”selected” to set which one starts selected)
(multiple=”multiple” in the select tag to define that multiple options can be selected)

&ltinput type=”file”/>

&ltinput type=”submit” name=”SUBMIT”/>
(value attribute to define what text is on the tag

&ltinput type=”image”/>
(same as submit)

&ltinput type=”hidden”>

&ltinput type=”date”/>

&ltinput type=”email”/>

&ltinput type=”number”/>

&ltinput type=”tel”/>

&ltinput type=”color”/>

textarea and select do not use the input type=”” format

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

When the form is inputted, ensure each input type is recognizable in the backend?

A

name=”name”

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

For those input types that do not have text or files as inputs, set the input value

A

value=”value”

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

use an image for a button

A

&ltbutton> &ltimg src etc> Add

&lt/button>

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

Make sure screen readers know what inputs are which

And expand clickable area to the text of the radio buttons for instance

A

&lt label> &lt input type=”blah”/> &lt/label>
or
&ltinput id=”female” type=”radio” name=”gender”
value=”f”>
&ltlabel for=”female”>Female&lt/label>

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

Group form items into a box
Label the box
(good for checkboxes and radios)
(good for screenreaders to be able to separate related form options)

A

&lt fieldset>
&lt legend> Text &lt/legend>
&lt/ fieldset>

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

Require a form entry to be filled in before submission (in html)

A

required=”required”
or just
required

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

Have placeholder text in certain text input elements

Have text already in the field

A

&ltinput type=”text” id=”first_name” placeholder=”greyed out text”>

&ltinput type=”text” id=”first_name” value=”prefilled text”>

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

Set the height and width of a textarea

A

&lttextarea rows=”20” cols=”60”>&lt/textarea>

18
Q

Setup a select group

A

optgroup (option group)

&ltselect name=”fashion”>
&ltoptgroup label=”Clothing”>
&ltoption value=”t_shirt”>T-Shirts&lt/option>
&ltoption value=”sweater”>Sweaters&lt/option>
&ltoption value=”coats”>Coats&lt/option>
&lt/optgroup>
&ltoptgroup label=”Foot Wear”>
&ltoption value=”sneakers”>Sneakers&lt/option>
&ltoption value=”boots”>Boots&lt/option>
&ltoption value=”sandals”>Sandals&lt/option>
&lt/optgroup>
&lt/select>

19
Q

How do radio buttons know which group they’re in?

A

the name attribute

20
Q

Types of buttons

A

type=”submit”
type=”reset”
type=”button” (generic)

21
Q

Why should you always set the button type?

A

a button within a form with the type value of submit <strong>(which happens to be the default value)</strong> will always try to make a new request and submit data back to the server. Hence, for buttons that are used within a form for different purposes other than submitting the data, the type attribute should always be specified to avoid unwanted effects of submitting a form.

22
Q

Make sure an element is read out loud a specific way

example, you want an input area to be required but if you add a *, it will read as “star” on screen readers

A

aria-label=”required”
And
add a title attribute for the sighted

23
Q

It’s better to use lists for forms

t or f

24
Q

Don’t use heading tags within a form

t or f

A

F

good practice to organize a form into lists.

25
How to define an email or phone number format? | Why do you need to?
the pattern attribute Some emails don't have a .com end there are many different phone number formats all around the world So the tel and email input types don't define a format
26
Make it so users can select multiple options on a <select> input by holding control
add the multiple attribute
27
Have suggested options for a text field
``` list attribute to a data list element <label for="myFruit">What's your favorite fruit?</label> <input type="text" name="myFruit" id="myFruit" list="mySuggestion"> <datalist id="mySuggestion"> <option>Apple</option> <option>Banana</option> <option>Blackberry</option> <option>Blueberry</option> <option>Lemon</option> <option>Lychee</option> <option>Peach</option> <option>Pear</option> </datalist> ```
28
Add ticks to a range input
``` <input type="range" list="tickmarks"> <datalist id="tickmarks"> <option value="0"></option> <option value="10"></option> <option value="20"></option> <option value="30"></option> <option value="40"></option> <option value="50"></option> <option value="60"></option> <option value="70"></option> <option value="80"></option> <option value="90"></option> <option value="100"></option> </datalist> ```
29
Add a progress bar
<progress max="100" value="75">75/100</progress>
30
add a meter bar (a sort of non moving progress bar to show other kinds of quantities) Make the colour change when the number gets past a certain point
<meter min="0" max="100" value="75" low="33" high="66" optimum="50">75</meter>
31
Change position of fieldset legend
fieldset { position: relative; } ``` legend { position: absolute; bottom: 0; right: 0; } ```
32
Form styling is often taken from the OS | Prevent OS styling
input { -webkit-appearance: none; appearance: none; } You will need both for different reasons ie search inputs on macOS need appearance: none
33
pseudoclass for checkboxes checked or not checked
:checked | :disabled
34
put something at the very beginning or end of an element like checkboxes in a checkbox or radio input or little arrow of a dropdown list at the end (pseudo-element)
::before | ::after
35
What are some pseudo classes relevant to forms | 6 groups
hover focus active required and optional valid, invalid, in-range, out-of-range (range is like with sliders) (valid is like when an email address doesn't match the valid format) enabled, disabled, read-only, read-write checked, indeterminate, default
36
What are form controls?
The input elements on a form that request the input data.
37
What is the name attribute for?
to set the key name for the form object in the backend. So we know what the data is.
38
Set a minimum and maximum length for text inputs
minlength="3" maxlength="30" attributes
39
Set a minimum and maximum number value for number inputs
min="1" | max="10"
40
Define an email, credit card or zip code format
pattern="(\d{5}([\-]\d{4})?)"
41
Make a text field REQUIRE banana or cherry
pattern="[Bb]anana|[Cc]herry" | it does B or b between [ ]