Final EXP 4
Final EXP 4
2. Objective: To teach taking inputs form users and validate the inputs using HTML/CSS
and JavaScript.
3. Lab outcome: After performing the experiment, the learner will be able to style web
page using CSS and make them responsive.
6. Related theory:
An HTML or a Web form helps collect user input. HTML forms can have different fields,
such as text areas, text boxes, radio buttons, checkboxes, drop-down lists, file uploads, etc.
The collected data can be validated on the client browser using JavaScript. After validation
of form data on the client-side, the user clicks on the Submit button in the form. After this,
data is sent to the server for further processing.
The process of creating a form using HTML/CSS:
HTML <form> element:
The HTML <form> element is used to create an HTML form. It starts with the
<form> tag and ends with the </form> tag. We can add the input elements within
the form tags for accepting user input.
</form>
</body>
</html>
Type Description
<input type="text"> Displays a single-line text input field
<input type="radio"> Displays a radio button (for selecting one of many choices)
<input type="checkbox"> Displays a checkbox (for selecting zero or more of many
choices)
<input type="submit"> Displays a submit button (for submitting the form)
<input type="button"> Displays a clickable button
<input type="date"> Defines a date picker. he appearance of the date picker input
UI varies based on the browser and operating system. The
value is normalized to the format yyyy-mm-dd.
<input type="email"> Displays a single-line text input field for entering email.
Apart from <input> elements, some other related elements are required.
The <label> tag defines a label for many form elements. The <label> element is useful
for screen-reader users, because the screen-reader will read out loud the label when the
user focuses on the input element.
The <label> element also helps users who have difficulty clicking on very small regions
(such as radio buttons or checkboxes) - because when the user clicks the text within the
<label> element, it toggles the radio button/checkbox.
The for attribute of the <label> tag should be equal to the id attribute of the <input>
element to bind them together.
7. Laboratory Exercise
A. Create a Registration Form using HTML and CSS. The form should contain fields
for first name, last name, birth date, gender, email and phone number. Also include one
submit button.
B. Use JavaScript to validate all the fields of the form.
B. Results/Observations/Program output:
Submit the written lab report to the teacher in-charge. The lab report includes print out of
the experiment-3 lab manual, hand written answers of post-experiment questions and
conclusion and screenshots of the form created by you along with all the test cases for form
validation. Upload folder of your .html, .css files on Google Classroom.
C. Conclusion:
Write what was performed in the experiment and which tools did you use for it. Write about
how can you make the websites interactive and dynamic.
D. References:
[1] HTML 5 Black Book, 2nd Ed, DT Editorial services, 2016
[2] HTML & CSS: The Complete Reference, 5th Ed., Thomas A. Powell, Mc Graw Hill, 2010
[3] JavaScript: The Good Parts, I Ed., Douglas Crockford, O’Reilly, 2008