forms Flashcards

1
Q

Name the attributes of form in HTML5.

A

autocomplete and novalidate

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

Give any three input attributes’ names.

A
autocomplete
autofocus
form
formaction
formenctype
formmethod
formnovalidate
formtarget
height and width
list
min and max
multiple
pattern (regexp)
placeholder
required
step
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Is input attribute “form” supported in IE?

A

It is not supported in IE.

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

Which web browsers support the input attribute “autofocus”?

A

Input attribute “autofocus” is supported by Firefox, Opera and Chrome.

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

Does Opera support the input attribute “novalidate”?

A

Starting from version 11, Opera supports the input attribute “novalidate”.

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

What does autocomplete attribute do?

A

he autocomplete attribute specifies that the form or input field should have an autocomplete function.

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

You have a form with multiple fields. You wish to automatically get focus on a field when a page gets loaded. Which field attribute will you use?

A

The autofocus attribute will be used.
e.g. ‹form›
‹input name=”q” autofocus›
‹input type=”submit” value=”Search”› ‹/form›

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

Does autofocus attribute work with all input types?

A

Yes, autofocus attribute works with all input types.

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

What does form attribute do?

A

The form attribute is used to specify one or more forms.

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

Give an example of form attribute.

A

‹form action=”from1.asp” method=”get” id=”form1”›

First name:‹input type=”text” name=”fname” /› ‹input type=”submit” /›

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

What does form override attribute do?

A

Some of the attributes set for the form element can be overridden using override attribute.

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

Explain the types of override attributes.

A

a) formaction - overrides the form action attribute
b) formenctype - overrides the form enctype attribute
c) formmethod - overrides the form method attribute
d) formnovalidate - overrides the form novalidate attribute e) formtarget - overrides the form target attribute

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

What is the main function of the override attribute types?

A

Override attribute types are helpful for creating different submit buttons.

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

Which attributes can be used to specify the dimensions of an image used for the input type image?

A

The height and width attributes specify the height and width of the image used for the input type image.

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

Give an example of input type image using width and height attributes.

A

‹input type=”image” src=”img_submit.gif” width=”24” height=”24” /›

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

What does a list attribute do?

A

The list attribute specifies a datalist for an input field.

[input list=”browsers”]

[datalist id="browsers"]
  [option value="Internet Explorer"]
  [option value="Firefox"]
  [option value="Chrome"]
  [option value="Opera"]
  [option value="Safari"]
[/datalist]
17
Q

Name the input attribute’s types with which the attribute “list” works.

A

The list attribute works with the input types namely text, search, url, telephone, email, date pickers, number, range, and color.

18
Q

How can you specify minimum and maximum value for an input field?

A

The min and max attributes of input field can be used to specify the minimum and maximum value for input field.
[form action=”demo_form.asp”]
Enter a date before 1980-01-01:
[input type=”date” name=”bday” max=”1979-12-31”]
Enter a date after 2000-01-01:
[input type=”date” name=”bday” min=”2000-01-02”]
Quantity (between 1 and 5):
[input type=”number” name=”quantity” min=”1” max=”5”]
[input type=”submit”]

[/form]

19
Q

Which datatypes are compatible with input tag’s min and max attributes?

A

input tag’s min and max attributes work with numbers or dates.

20
Q

What does step attribute do?

A

The step attribute is used to specify legal number intervals for the input field.

21
Q

What will be the legal allowed values for the following?‹input type=”number” name=”points” min=”0” max=”10” step=”3” /›

A

0, 3, 6.9

22
Q

Give an example which shows a numeric field that accepts values between 0 and 10, with a step of 3.

A

Points: ‹input type=”number” name=”test” min=”0” max=”10” step=”3” /›

23
Q

Which attribute specifies that multiple values can be selected for an input field?

A

The multiple attribute

24
Q

With which input types does the multiple attribute work?

A

The multiple attribute works with the input type file and email. e.g. Select: ‹input type=”file” name=”img” multiple=”multiple” /›

25
Q

You have a form and you do not want any form validation over it. Which HTML5 attribute is to be used?

A

The novalidate attribute is used to submit not validated form data.

26
Q

Will you prefer HTML5 form validation over JavaScript form validation? Why?

A

Yes. There are two reasons for this:

a) I have to write and maintain JavaScript form validation script.
b) If a user has disabled JavaScript on his web browser, then JavaScript form validation will be bypassed.

27
Q

Will HTM5 form validation work on a compatible web browser if scripting is disabled?

A

Yes. The browser will do RFC-compliant email validation on form submission.

28
Q

Given an example of a form that submits unvalidated data.

A

‹form action=”demo_form.asp” novalidate=”novalidate”›
E-mail: ‹input type=”email” name=”user_email” /›
‹input type=”submit” /› ‹/form›

29
Q

What does a pattern attribute do?

A

The pattern attribute specifies a pattern used to validate an input field. A valid regular expression needs to be provided when using pattern attribute.

30
Q

Name the input attribute types with which the attribute “pattern” works.

A

The pattern attribute works with the types: text, search, url, telephone, email, and password.

31
Q

Give an example of pattern attribute.

A

In the following example, country code pattern is specified for validation. Country code: ‹input type=”text” name=”country_code” pattern=”[A-z]{3}” title=”Three letter country code” /›

32
Q

What does a placeholder attribute do?

A

The placeholder attribute is used to provide a hint to the user about the expected value of an input field.

33
Q

Name the input attribute types with which the attribute “placeholder” works.

A

The placeholder attribute works with the following types: text, search, url, telephone, email, and password.

34
Q

What does a required attribute do?

A

A required attribute is a way to make a form field mandatory. User has to fill it in order to successfully submit the form.

35
Q

Name the input attribute types with which the attribute “required” works.

A

The required attribute works with the following types: text, search, url, telephone, email, password, date pickers, number, checkbox, radio, and file.

36
Q

Give an example to show the usage of required attribute.

A

The following example makes the input field mandatory.

You name: ‹input type=”text” name=”usr_name” required=”required” /›