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

A

t

24
Q

Don’t use heading tags within a form

t or f

A

F

good practice to organize a form into lists.

25
Q

How to define an email or phone number format?

Why do you need to?

A

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
Q

Make it so users can select multiple options on a &ltselect> input by holding control

A

add the multiple attribute

27
Q

Have suggested options for a text field

A
list attribute to a
data list element
&ltlabel for="myFruit">What's your favorite fruit?&lt/label>
&ltinput type="text" name="myFruit" id="myFruit" list="mySuggestion">
&ltdatalist id="mySuggestion">
  &ltoption>Apple&lt/option>
  &ltoption>Banana&lt/option>
  &ltoption>Blackberry&lt/option>
  &ltoption>Blueberry&lt/option>
  &ltoption>Lemon&lt/option>
  &ltoption>Lychee&lt/option>
  &ltoption>Peach&lt/option>
  &ltoption>Pear&lt/option>
&lt/datalist>
28
Q

Add ticks to a range input

A
&ltinput type="range" list="tickmarks">
&ltdatalist id="tickmarks">
&ltoption value="0">&lt/option>
&ltoption value="10">&lt/option>
&ltoption value="20">&lt/option>
&ltoption value="30">&lt/option>
&ltoption value="40">&lt/option>
&ltoption value="50">&lt/option>
&ltoption value="60">&lt/option>
&ltoption value="70">&lt/option>
&ltoption value="80">&lt/option>
&ltoption value="90">&lt/option>
&ltoption value="100">&lt/option>
&lt/datalist>
29
Q

Add a progress bar

A

&ltprogress max=”100” value=”75”>75/100&lt/progress>

30
Q

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

A

&ltmeter min=”0” max=”100” value=”75” low=”33” high=”66” optimum=”50”>75&lt/meter>

31
Q

Change position of fieldset legend

A

fieldset {
position: relative;
}

legend {
  position: absolute;
  bottom: 0;
  right: 0;
}
32
Q

Form styling is often taken from the OS

Prevent OS styling

A

input {
-webkit-appearance: none;
appearance: none;
}

You will need both for different reasons
ie search inputs on macOS need appearance: none

33
Q

pseudoclass for checkboxes checked or not checked

A

:checked

:disabled

34
Q

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)

A

::before

::after

35
Q

What are some pseudo classes relevant to forms

6 groups

A

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
Q

What are form controls?

A

The input elements on a form that request the input data.

37
Q

What is the name attribute for?

A

to set the key name for the form object in the backend. So we know what the data is.

38
Q

Set a minimum and maximum length for text inputs

A

minlength=”3”
maxlength=”30”
attributes

39
Q

Set a minimum and maximum number value for number inputs

A

min=”1”

max=”10”

40
Q

Define an email, credit card or zip code format

A

pattern=”(\d{5}([-]\d{4})?)”

41
Q

Make a text field REQUIRE banana or cherry

A

pattern=”[Bb]anana|[Cc]herry”

it does B or b between [ ]