Q3 MODULE3 G10 PROGRAMMING MANGALDAN-NHS-Final
Q3 MODULE3 G10 PROGRAMMING MANGALDAN-NHS-Final
10
TVL- ICT
COMPUTER PROGRAMMING
QUARTER 3 – MODULE 3
HTML – FORM CONTROLS
Prepared by:
EUGENIO L. MOLINA
Teacher III
Mangaldan National High School
QUARTER III
WEEK III
I. LEARNING OBJECTIVES
After reading this module you will be able to understand how to create form, textbox,
password, text area and checkbox and identify their different attributes.
II. INTRODUCTION
HTML Forms are required when you want to collect some data from the site visitor. For
example, during user registration you would like to collect information such as name, email
address, credit card, etc. There are various form elements available like text fields, textarea
password, and checkboxes.
III. READINGS/LECTURES
Syntax:
<form>
....
Form Elements..
....
</form>
There are different types of form controls that you can use to collect data using HTML form
1
HTML Forms Element
Example
<!DOCTYPE html>
<html>
<head>
<title> HTML Form Input Attribute </title>
</head>
<body>
<form>
First name:
<input type="text" name="firstname">
Last name:
<input type="text" name="lastname">
</form>
</body>
</html>
• Password input controls − This is also a single-line text input but it masks the
character as soon as a user enters it. They are also created using HTML <input> tag.
2
• Multi-line text input controls − This is used when the user is required to give details
that may be longer than a single sentence. Multi-line input controls are created using
HTML <textarea> tag.
This control is used for items that require only one line of user input, such as search
boxes or names. They are created using HTML <input> tag.
Example
Here is a basic example of a single-line text input used to take first name and last name
<!DOCTYPE html>
<html>
<head>
<title>Text Input Control</title>
</head>
<body>
<form >
First name: <input type = "text" name = "first_name" />
<br>
Last name: <input type = "text" name = "last_name" />
</form>
</body>
</html>
This will produce the following result
Here is the list of attributes for <input> tag for creating text field.
type
Indicates the type of input control and for text input control it will be set to text.
Name
Used to give a name to the control which is sent to the server to be recognized and get the
value.
Value
This can be used to provide an initial value inside the control.
3
Size
Allows to specify the width of the text-input control in terms of characters.
Maxlength
Allows to specify the maximum number of characters a user can enter into the text box.
This is also a single-line text input but it masks the character as soon as a user enters
it. They are also created using HTML <input>tag but type attribute is set to password.
Example
Here is a basic example of a single-line password input used to take user password
<!DOCTYPE html>
<html>
<head>
<title>Password Input Control</title>
</head>
<body>
<form >
User ID : <input type = "text" name = "user_id" />
<br>
Password: <input type = "password" name = "password" />
</form>
</body>
</html>
This will produce the following result
Here is the list of attributes for <input> tag for creating password field.
type
Indicates the type of input control and for password input control it will be set
to password.
name
Used to give a name to the control which is sent to the server to be recognized and get
the value.
4
value
This can be used to provide an initial value inside the control.
size
Allows to specify the width of the text-input control in terms of characters.
maxlength
Allows to specify the maximum number of characters a user can enter into the text box.
This is used when the user is required to give details that may be longer than a single
sentence. Multi-line input controls are created using HTML <textarea> tag.
Example
Here is a basic example of a multi-line text input used to take item description
<!DOCTYPE html>
<html>
<head>
<title>Multiple-Line Input Control</title>
</head>
<body>
<form>
Description : <br />
<textarea rows = "5" cols = "50" name = "description">
Enter description here...
</textarea>
</form>
</body>
</html>
This will produce the following result
5
Here is the list of attributes for <textarea> tag.
name
Used to give a name to the control which is sent to the server to be recognized and
get the value.
rows
Indicates the number of rows of text area box.
cols
Indicates the number of columns of text area box
Checkbox Control
Checkboxes are used when more than one option is required to be selected. They are
also created using HTML <input> tag but type attribute is set to checkbox.
Example
Here is an example HTML code for a form with two checkboxes
<!DOCTYPE html>
<html>
<head>
<title>Checkbox Control</title>
</head>
<body>
<form>
<input type = "checkbox" name = "math" checked> Math
<input type = "checkbox" name = "physics"> Physics
</form>
</body>
</html>
This will produce the following result
6
Here is the list of attributes for <checkbox> tag.
type
Indicates the type of input control and for checkbox input control it will be set
to checkbox.
name
Used to give a name to the control which is sent to the server to be recognized and get
the value.
value
The value that will be used if the checkbox is selected.
checked
Set to checked if you want to select it by default.
ACTIVITY 1: Identify whether the given attribute is for Input, Text Area or Checkbox.
Write your answers in your answer sheet.
1. maxlength 6. rows
2. cols 7. checked
3. name 8. type”=checkbox”
4. size 9. value
5. cols=”60” 10. type=”password”
7
SUMMATIVE EVALUATION
6. Indicates the type of input control and for text input control it will be set to text.
8. Allows to specify the maximum number of characters a user can enter into the text
box.
9. This can be used to provide an initial value inside the control.
10. This is also a single-line text input but it masks the character as soon as a user
enters it.
B. Copy the given HTML codes and encircle the error(s). Write your answer in your
answer sheet.
8
C. Create the HTML Code for the following. Write them in your answer sheet.
1.
CODE:
2.
CODE:
9
Key Answer
1. Input
2. Text Area
3. Input / Text Area / Checkbox
4. Input
5. Text Area
6. Text Area
7. Checkbox
8. Checkbox
9. Input / Checkbox
10. Input
Reference: https://www.tutorialspoint.com/html/html_comments.htm
Learn to Code HTML & CSS –Develop and Style Website by: Shay Howe
10
ANSWER SHEET
11