Form_MCQ
Form_MCQ
Answer: a
Explanation: Text input type defines single line text field. Type is the attribute that displays type of
<input> elements. Its default type is text. It is supported by most of the browsers like Chrome,
Internet Explorer, Firefox, Opera. Syntax is: <form action=”jump.php”> Name:<input type=”text”
name=”name”> </form> A password field is defined by password input.
2. Which of the following is a new input attribute introduce by HTML5?
a) text
b) checkbox controls
c) submit buttons
d) date
View Answer
Answer: d
Explanation: HTML4 has attributes with <input> elements like radio buttons, Checkbox controls,
submit buttons, text input etc.
HTML5 has introduced new attributes like date, color, month, time, week, datetime-local, email,
number, range, tel, url, search etc.
3. How does the color attribute work?
a) Changes color of the text
b) Changes background color
c) The color picker is defined by it
d) Changes color of the text as well as background
View Answer
Answer: c
Explanation: color is the attribute of <input> element introduce by HTML5. It defines the color picker
i.e we can select a color of our choice from the color picker. Syntax is Select the color that you want:
<input type=”color” name=”favorite color”>
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!
advertisement
Answer: a
Explanation: Input type button is used for the activation of JavaScript on the clicking of the button. Its
syntax is <input type=”button” value=”click” onclick=”source()”>. This will display a button named
click and when we click that button JavaScript function source() will be invoked.
5. Which attribute defines the file-select field?
a) file
b) checkbox
c) button
d) text
View Answer
Answer: a
Explanation: file input type defines a file-select field, also gives a “Browse” button for file uploads.
Syntax is <input type=”file” name=”image”>. Checkbox gives the facility to select one or more than one
options from the given choices. The button activates JavaScript code. The text defines a single-line text
field.
Check this: Information Science MCQs | Computer Science Books
6. How image attribute works?
a) Sets an image background
b) Set an image as submit button
c) Set an image anywhere on the page
d) Bring default image to the page
View Answer
Answer: b
Explanation: the image input type set an image as submit button. The syntax is <input type=”image”
src=”imghj.gif” alt=”Submit”> this sets the image provided by url as the submit button. Input type
image sends the X and Y coordinates of click and hence the image is activated by clicking the submit
button.
7. month attribute defines ___________
a) the only month
b) month and year
c) date
d) date and time
View Answer
Answer: b
Explanation: month and year are defined by month attribute. It does not define the time zone. The
syntax is Anniversary (month and year) <input=”month” name=”anniversary month” >., date attribute
defines the date, datetime-local defines date and time but no time zone.
8. week attribute defines ____________
a) week
b) year
c) week and year
d) week, month and year
View Answer
Answer: c
Explanation: week input type defines a week and year. It does not define the time zone. Syntax is
<form action=”ghu.php”> week: <input type=”week” name=”week and year”> <input type=”submit”>
</form>, this gives a selection box and display a calendar like chart from where we can select a week
and the year as well.
9. tel attribute is supported by the _________ browser.
a) Chrome
b) Safari
c) Opera
d) Internet Explorer
View Answer
Answer: b
Explanation: tel is the attribute which specifies field for telephone number. Syntax is <form
action=”hkjk.php”> Telephone number: <input type=”tel” name=”usertelephone”> <br> <input
type=”submit”> </form>, tel attribute is usually supported by newer versions like Safari 8.
10. Which attribute is not used on new forms?
a) size
b) text
c) name
d) maxlength
View Answer
Answer: a
Explanation: size attribute denotes the width of text input i.e measured by the number of characters
inputted. E.g. If we input value 3 then it will create a box of width enough to display three characters.
The user can enter more characters if they want. Syntax is <input type=”text” name=”firstname”
size=”12” maxlength=”30”>
11. Which of the following is not used with password attribute?
a) name
b) size
c) maxlength
d) min
View Answer
Answer: d
Explanation: password is the attribute that creates a text box which is similar to the single line text
input, but the characters are blocked out. They are hidden due to the privacy of the user. The name
attribute with a password set the name of the password input, size and maxlength attributes define
the size and maximum length of the text box which is to be used for the password.
12. Which element is used to create multi-line text input?
a) text
b) textarea
c) submit
d) radio button
View Answer
Answer: b
Explanation: For creating multi-line text input we use <textarea> element. This is not empty element
i.e. it requires both opening tag and closing tag. The cols attribute defines a width of the text area. The
row attributes the number of rows that the textarea can require.
13. Which attribute is not used for the radio type?
a) name
b) value
c) checked
d) selected
View Answer
Answer: d
Explanation: When we want to pick one option from the given many options we use radio type. Name
attribute sent the value of the option selected to the server. Value attribute indicates the value that
has been sent to the server for the selected option. The checked attribute indicates that which value
should be selected on the loading of the page.
14. Which attribute is used with <select> element?
a) multiple
b) selected
c) name
d) value
View Answer
Answer: a
Explanation: <select> element is used for drop down select box. Size attribute is used for showing
more than one option. For a selection of multiple options, we use multiple attributes. It is a useful
option to select multiple things at a time.
Syntax is
<form action=”jhi.php”> <select name=”fruits” size=”5” multiple=”multiple”>
Answer: a
Explanation: The correct syntax of HTML5 doctype is <!doctype html>, doctype is the very first thing
to write in HTML5. <!doctype html> or <!DOCTYPE HTML> both are same because ‘doctype’ keyword
is not case sensitive.
What if one does not use the doctype in the starting of HTML document?
a) Browser finds the document in quirky mode
b) Browser finds a document in standard mode
c) Browser stops working
d) Browser crashes after showing the page
View Answer
Answer: a
Explanation: If the browser finds <!doctype html> in the starting of an HTML document it sets the
document in standard mode but if one does not use a doctype, the browser goes to quirky mode. In
this mode, certain content will not be displayed as per one wrote that. So it is always recommended to
write a doctype at the very start of the HTML document.
Which attribute is used to specify the minimum value allowed for an input field?
A) min
B) max
C) required
D) pattern
Answer: A
Which attribute is used to specify the maximum value allowed for an input field?
A) max
B) min
C) required
D) pattern
Answer: A
Which attribute is used to specify the pattern that an input field's value must match?
A) pattern
B) validate
C) check
D) format
Answer: A
Which attribute is used to specify the maximum length of an input field's value?
A) maxlength
B) minlength
C) length
D) maxchars
Answer: A
Which attribute is used to specify a custom error message for an input field?
A) title
B) message
C) error-message
D) data-message
Answer: A
Which attribute is used to specify that an input field's value must be a valid email address?
A) type="email"
B) pattern="\b[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,}\b"
C) validate="email"
D) email="true"
Answer: A
Which attribute is used to specify that an input field's value must be a valid URL?
A) type="url"
B) pattern="\b(http|https)://[A-Za-z0-9.-]+.[A-Za-z]{2,}\b"
C) validate="url"
D) url="true"
Answer: A
Which attribute is used to specify that an input field's value must be a number?
A) type="number"
B) pattern="[0-9]+"
C) validate="number"
D) number="true"
Answer: A
Which attribute is used to specify that an input field's value must be a date?
A) type="date"
B) pattern="\d{4}-\d{2}-\d{2}"
C) validate="date"
D) date="true"
Answer: A
Which attribute is used to specify that an input field's value must be a time?
A) type="time"
B) pattern="\d{2}:\d{2}"
C) validate="time"
D) time="true"
Answer: A
Which attribute is used to specify that an input field's value must be a valid credit card number?
A) type="credit-card"
B) pattern="\d{4}-\d{4}-\d{4}-\d{4}"
C) validate="credit-card"
D) credit-card="true"
Answer: A
Which attribute is used to specify that an input field's value must be a valid phone number?
A) type="tel"
B) pattern="\d{3}-\d{3}-\d{4}"
C) validate="phone"
D) phone="true"
Answer: A
Which attribute is used to specify the error message to display when an input field's value does not
meet its validation criteria?
A) data-error-message
B) error-message
C) message
D) title
Answer: A